2013年10月22日星期二

OutputStream

import java.io.File ;
import java.io.Writer ;
import java.io.FileWriter ;
public class WriterDemo02{
public static void main(String args[]) throws Exception{
File f= new File("d:" + File.separator + "test.txt") ;
Writer out = null ;
out = new FileWriter(f)  ;
String str = "\nhello\nHello World!!!" ;
out.write(str) ;
out.close() ;
}
};

code \ n newline how not achieve the role ? Must use \ r \ n job ( I have tested in win7 jdk1.6 ) Why is this ?
------ Solution ---------------------------------------- ----
file inside wrap wrap with java inside different
------ Solution ----------------------- ---------------------
windows system is \ r \ n, linux is \ n, you can use the buffer class newLine () method to improve compatibility < br> ------ Solution ----------------------------------------- ---
you use Notepad to open it, use Notepad , then we must use \ r \ n newline , if \ n you use another text editor to open can also wrap
---- - For reference only ---------------------------------------
upstairs the correct
------ For reference only ---------------------------------- -----
+1, has been explained very clearly
------ For reference only --------------------- ------------------
positive solution
------ For reference only ---------------- -----------------------
2floor right
------ For reference only --------- ------------------------------
justdoingtest
------ For reference only ---- -----------------------------------


+1
------ For reference only -------------------------------- -------
according to you for answering my own test it looks like in Notepad \ r \ n means a newline in some other text editor \ n or \ r \ n are can be expressed wrap.

没有评论:

发表评论