package 文件读取;
import java.io.*;
import java.util.*;
public class File {
public static void main(String[] args)throws Exception
{
FileReader file_source=null;
FileWriter file_destination=null;
try
{
file_source=new FileReader("D:/a.txt");
file_destination=new FileWriter("D:/b.txt");
char[] buf=new char[1024];
int len=0;
while((len=file_source.read(buf))!=-1)
{
// Sort(buf);
Arrays.sort(buf);
System.out.println(buf);
file_destination.write(buf,0,len);
file_destination.flush();
}
}
catch(IOException e)
{
e.printStackTrace();
}
finally
{
try
{
if(file_source!=null)
file_source.close();
}
catch(IOException e)
{
e.printStackTrace();
}
try
{
if(file_destination!=null)
file_destination.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
}
来源:https://www.cnblogs.com/abcde12345/p/9258636.html