展开全部
@org.junit.Test
public void test3() throws Exception{
BufferedReader b=new BufferedReader(new InputStreamReader(new FileInputStream(new File("c:/a.txt"))));
String a=null;
String txt="";
while ((a=b.readLine())!=null) {
txt=txt+a;
}
System.err.println(txt);
String[] txts=txt.split("");
Arrays.sort(txts);
BufferedWriter w=new BufferedWriter(new FileWriter(new File("c:/a.txt")));
for (String string : txts) {
if (string!=null&&!string.equals("")) {
w.append(string);
}
//System.err.println(string);
}
w.flush();
//System.err.println(txts.toString());
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询