Home > Java > Javagetting Started > How to wrap line in java

How to wrap line in java

(*-*)浩
Release: 2019-11-14 11:12:42
Original
15894 people have browsed it

How to wrap line in java

java中实现换行有以下几种方法:

1.使用java中的转义符"\r\n":            (推荐学习:java课程

String str="aaa";
str+="\r\n";
Copy after login

这样在str后面就有换行了.

注意:\r,\n的顺序是不能够对换的,否则不能实现换行的效果。

2.BufferedWriter的newline()方法:

FileOutputStream fos=new FileOutputStream("c;\\11.txt");
BufferedWriter bw=new BufferedWriter(fos);
bw.write("你好");
bw.newline();
bw.write("java");
w.newline();
Copy after login

3.使用System.getProperty()方法:

String str = "aaa"+System.getProperty("line.separator");
Copy after login

The above is the detailed content of How to wrap line in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template