Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
472 views
in Technique[技术] by (71.8m points)

java - Difference between System.getProperty("line.separator"); and " "?

While developing GUI with Java FX, I seem to get different results with System.getProperty("line.separator"); and " " during writing to a file or getting data from internet. What basically is the difference?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

System.getProperty("line.separator") returns the OS dependent line separator.

On Windows it returns " ", on Unix " ". So if you want to generate a file with line endings for the current operating systems use System.getProperty("line.separator") or write using a PrintWriter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...