注:回车换行
windows中:"\r\n"
linux:"\n"
1.字节输出流
FileOutputStream fos=new FileOutputStream("charstream\\a.txt");
fos.write(97);
fos.write("\r\n".getBytes());
fos.write(98);
2.字符输出流
Scanner sc=new Scanner(System.in);
System.out.println("请输入用户名:");
String username=sc.next();
System.out.println("请输入密码:");
String password=sc.next();
FileWriter fw=new FileWriter(new File("charstream\\a.txt"));
fw.write(username);
fw.write("\n");
fw.write(password);
fw.flush();
fw.close();
3. .newLine();跨平台回车换行