English 中文(简体)
我怎么能够打破 Java的扼杀?
原标题:How can I break the string on Java?
  • 时间:2012-01-12 19:06:33
  •  标签:
  • java

我需要将插图写成<条码>ByteArrayOutputStre,但我需要用打断书写。 我试图这样做,例如:

out.write("123".getBytes());
out.write("
456".getBytes());

But doesn t work. Please, tell me, how can I fix it? Or suggest me alternative OutputStream for storing strings (this OS must allow to use breaking of lines) without making files. Thank 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 that this will generate platform-specific bytes. Newlines can be , or . The actual character sequence used is specified in system property line.separator.

Just use BufferedWriter 它将为您管理线间休息(bwinstance.newLine()。 无论由哪位顾问担任。

如果你正在寻找一个独立的新分界线,我建议使用:

System.getProperty("line.separator");

我不每次打上<条码>植被(<>条码/代码”),而是将这一价值储存在一个可适当检索的变量中。

如果你在撰写论文之前正在建造座椅,这也是一种理想的方法,因为这样,你就不必单独书写每一行。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签