How can I break the string on Java? -
How can I break the string on Java? -
i need write strings bytearrayoutputstream
, need write strings breaking. have tried example:
out.write("123".getbytes()); out.write("\n456".getbytes());
but '\n' doesn't work. please, tell me, how can prepare it? or suggest me alternative outputstream storing strings (this os must allow utilize breaking of lines) without making files. give thanks you.
bytearrayoutputstream stream = ...; printstream printer = new printstream(stream, true); // auto-flush printer.println("123"); // writes newline printer.print("hello"); // no new line printer.print(" world"); printer.println();
note generate platform-specific bytes. newlines can \n
, \r\n
or \r
. actual character sequence used specified in system property line.separator
.
java
Comments
Post a Comment