Is there an easy way to concatenate several lines of text into a string without constantly appending
Posted
by Marshmellow1328
on Stack Overflow
See other posts from Stack Overflow
or by Marshmellow1328
Published on 2010-03-24T15:54:32Z
Indexed on
2010/03/24
16:13 UTC
Read the original article
Hit count: 240
So I essentially need to do this:
String text = "line1\n";
text += "line2\n";
text += "line3\n";
useString( text );
There is more involved, but that's the basic idea. Is there anything out there that might let me do something more along the lines of this though?
DesiredStringThinger text = new DesiredStringThinger();
text.append( "line1" );
text.append( "line2" );
text.append( "line3" );
useString( text.toString() );
Obviously, it does not need to work exactly like that, but I think I get the basic point across. There is always the option of writing a loop which processes the text myself, but it would be nice if there is a standard Java class out there that already does something like this rather than me needing to carry a class around between applications just so I can do something so trivial.
Thanks!
© Stack Overflow or respective owner