Coming from Perl, I sure am missing the \"here-document\" means of creating a multi-line string in source code:
$string = <<\"EOF\" # create a three-l
This is an old thread, but a new quite elegant solution (with only 4 maybe 3 little drawbacks) is to use a custom annotation.
Check : http://www.adrianwalker.org/2011/12/java-multiline-string.html
A project inspired from that work is hosted on GitHub:
https://github.com/benelog/multiline
Example of Java code:
import org.adrianwalker.multilinestring.Multiline; ... public final class MultilineStringUsage { /**
Hello
*/ @Multiline private static String html; public static void main(final String[] args) { System.out.println(html); } }
Multiline
World
The drawbacks are
<%= variable %>
) :-)And you probably have to configure Eclipse/Intellij-Idea to not reformat automatically your Javadoc comments.
One may find this weird (Javadoc comments are not designed to embed anything other than comments), but as this lack of multiline string in Java is really annoying in the end, I find this to be the least worst solution.