<img alt="" src="https://img-blog.csdn.net/20140326235338187?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzk5NjQ2NA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" /><img alt="" src="https://img-blog.csdn.net/20140326235338187?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzk5NjQ2NA==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" />import java.util.ArrayList;
import java.util.List;
import java.io.BufferedReader;
import java.io.Reader;
import java.io.File;
import java.io.FileReader;
import java.util.Collections;
public class Test {
public static void main(String[] args){
Test2 test=new Test2();
test.order("D:\\largeW.txt");
}
}
class Test2{
Test2(){}
void order(String PathName){
long sum=0;
List<Integer> list=new ArrayList<Integer>();
try{
File file=new File(PathName);
BufferedReader bufferedReader=new BufferedReader(new FileReader(file));
String s=null;
while((s=bufferedReader.readLine())!=null){
list.add(Integer.parseInt(s.trim()));
sum++;
}
Collections.sort(list);
}catch(Exception e){
System.err.println("读取文件的时候,发生错误!"+e.toString());
}
System.err.println("读取文件完毕~~~~总条数:"+sum);
for(int s:list){
System.out.print(" "+s);
}
}
}
第三周作业归并排序
最新推荐文章于 2020-03-17 20:22:05 发布