标签:
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; /* * 读取txt格式文本,并复制保存 */ public class ReadFile { public static void main(String args[]) throws IOException{ File file = new File("/Users/xiaobai/testData/test1.txt"); BufferedReader read = new BufferedReader(new FileReader(file)); File file1 = new File("/Users/xiaobai/testData/test2.txt"); BufferedWriter writer = new BufferedWriter(new FileWriter(file1)); String text = null; while((text = read.readLine()) != null){ System.out.println(text); writer.write(text); writer.newLine(); writer.flush(); } read.close(); writer.close(); } }
标签:
原文地址:http://www.cnblogs.com/worms/p/5726607.html