22.5

 1 import java.io.File;
 2 import java.io.FileNotFoundException;
 3 import java.util.*;
 4 
 5 public class S22_5 {
 6 
 7     public static void main(String[] args) {
 8         // TODO Auto-generated method stub
 9         List<String> myList = new ArrayList<String>();
10     
11             Scanner input = null;
12             try {
13                 input = new Scanner(new File("txt.txt"));
14             } catch (FileNotFoundException e) {
15                 // TODO Auto-generated catch block
16                 e.printStackTrace();
17             }
18             while(input.hasNext()){
19                 myList.add(input.next());
20             }
21             Collections.sort(myList);
22             for(String list:myList)
23             System.out.println(list);
24     }
25 }
View Code

 

posted on 2016-11-12 18:17  功夫茶茶  阅读(187)  评论(0编辑  收藏  举报

导航