Carriage Return\Line feed in Java

后端 未结 6 913
滥情空心
滥情空心 2020-12-12 21:46

I have created a text file in Unix environment using Java code.

For writing the text file I am using java.io.FileWriter and BufferedWriter.

6条回答
  •  感情败类
    2020-12-12 22:28

    If I understand you right, we talk about a text file attachment. Thats unfortunate because if it was the email's message body, you could always use "\r\n", referring to http://www.faqs.org/rfcs/rfc822.html

    But as it's an attachment, you must live with system differences. If I were in your shoes, I would choose one of those options:

    a) only support windows clients by using "\r\n" as line end.

    b) provide two attachment files, one with linux format and one with windows format.

    c) I don't know if the attachment is to be read by people or machines, but if it is people I would consider attaching an HTML file instead of plain text. more portable and much prettier, too :)

提交回复
热议问题