File file=new File("newhello.txt"); if(file.exists()&&file.isFile()) { try { //创建文件输入流 FileInputStream fis=new FileInputStream(file); //文件输入流读取 InputStreamReader isr=new InputStreamReader(fis); //创建带有缓冲的读取流 BufferedReader br=new BufferedReader(isr); String lineString; while ((lineString=br.readLine())!=null) { System.out.println(lineString); } System.out.println("读取完成"); br.close(); isr.close(); fis.close(); File file2=new File("newhello2.txt"); FileOutputStream fos=new FileOutputStream(file2); OutputStreamWriter osWriter=new OutputStreamWriter(fos); BufferedWriter bw=new BufferedWriter(osWriter); bw.write("你麻痹啊 "); bw.write("你2麻痹啊 "); bw.write("你3麻痹啊 "); bw.close(); osWriter.close(); fos.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }