import java.io.*;
 
import javax.swing.JOptionPane;
 
public class test {
 public static void main(String []args){
 
 try{
 FileInputStream fis=new FileInputStream("namefile.txt");
 InputStreamReader dis=new InputStreamReader(fis);
 BufferedReader reader=new BufferedReader(dis);
 String s,str="";
 
 while((s=reader.readLine())!=null){
 str+=s;
 str+="/r/n";
 System.out.println(str);
 }
 
 dis.close();
 FileOutputStream fos=new FileOutputStream("namefile.txt");
 DataOutputStream dos=new DataOutputStream(fos);
 //BufferedWriter writer=new BufferedWriter(dos);
 String ss="TonHankes";
 str=str+ss;
 dos.writeChars(str);
 dos.close();
 }
 catch(IOException e){
 System.out.println(e);
 }
 }
 
}
 

  这是一个我写的关于文件写入的代码,但不知道怎么实现换行,"/r/n"也不奏效