慕雪6173905
参考这个import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io.FileWriter;import java.text.DecimalFormat;import java.util.Random;
public class Test {
public static void main(String[] args) throws Exception {
File src = new File("D:\\src.txt");File dest = new File("D:\\dest");FileReader fr = new FileReader(src);BufferedReader br = new BufferedReader(fr);int lineno = 1;int index = 1;dest.mkdirs();FileWriter fw = new FileWriter(new File(dest, creIndex(index++)
".txt"));
(br.ready()) {
(lineno++ % 500 == 0) {fw.close();
= new FileWriter(new File(dest, creIndex(index++) + ".txt"));}String line = br.readLine();fw.write(line + "\r\n");}fw.close();br.close();fr.close();}
public static String creIndex(int num) {DecimalFormat df = new DecimalFormat("00");return df.format(num);}
}