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 }
时间: 2024-10-18 05:46:28