Java file Operation new problem how to resolve Notepad wrapping line

Source: Internet
Author: User

See on the CSDN, because use Java to write to Notepad on the line problem, see this article, reprinted a bit. Oh.

I hope you can see it later.

Today, I did a Java file read and write, the original thought will be Java database OK, but now a look, read and write files, threads and other issues are all very important AH. Oh, good to cut to the chase, today's problem is when I write to a notepad input stream, when all finished, open Notepad a look, inside all is the secret of the text, there is no line, and then I write a sentence plus a "/n", but then open Notepad found that any change in the output "n" Places have become, But when I open the world, or WordPad, or even Dreamweaver 8, there's a new line, what's going on here. Is it a coding problem ... Right, this is the problem, I checked the data, found Notepad line symbol is "/r/n". Hehe, plus after the problem all resolved, in fact, this is not a big problem, but I still want to send out, convenient for others is convenient for themselves, because I also find information on the Internet, if no one posted words I will not so quickly solve this problem, so here also have to thank the unknown recognition.
Again, the line in Notepad is "/r/n".
If you want to do cross-platform use, you may need to use
String str= system.getproperty ("Line.separator");
To get line breaks.

Linux uses/n
Windows uses/r/n
Other operating systems may also be different. Thanks to Weacer here, the back is what he raised, just here I wrote it

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.