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() ;
}
};
代码中的\n怎么起不到换行的作用?必须要用\r\n才行(我在win7 jdk1.6中测试的)这是为什么?
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() ;
}
};
代码中的\n怎么起不到换行的作用?必须要用\r\n才行(我在win7 jdk1.6中测试的)这是为什么?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货