Java按行读取文本文件并保存

简单的描述,从一个文件夹下面读取txt 的每一行读取并保存依次排序的txt中 或者你可以更改成一个目录
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.PrintWriter;
public class Accuracy {

	//类似于此
	public static void main(String[] args) throws Exception {
			BufferedReader reader = new BufferedReader(new FileReader("D:\\stanford\\1111111cmn0302.txt"));
			String line = reader.readLine();
			int k=0;
			//fromFile = new BufferedReader(fr);
			while(line != null){
				     String[] list = null;
                     list = line.split(":");
//                     System.out.println("Success");
//                        System.out.print(list[0]);         
					  File file = new File("D:\\stanford\\"+k+".txt");
					  file.createNewFile();

					  PrintWriter output = new PrintWriter(file);
					  for(int i=0;i

你可能感兴趣的:(JAVA)