Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 KB | None | 0 0
  1. public static void generatePhoneList(String file) throws FileNotFoundException {
  2.         int lineCount = 0;
  3.         List<String> firstN = new ArrayList<String>();
  4.         List<String> lastN = new ArrayList<String>();
  5.         List<String> city = new ArrayList<String>();
  6.         List<String> phone = new ArrayList<String>();
  7.         List<String> lastId = new ArrayList<String>();
  8.         List<String> votingHistory = new ArrayList<String>();
  9.        
  10.        
  11.        
  12.        
  13.         Scanner scanner = new Scanner(new File(file + ".txt"));
  14.         PrintWriter writer = new PrintWriter(file + "_PL.txt");
  15.        
  16.  
  17.         while(scanner.hasNextLine()) {
  18.             int voteCount = 0;
  19.            
  20.            
  21.             lineCount++;
  22.             String[] parts = scanner.nextLine().split("|");
  23.            
  24.             for(String s : parts) {
  25.                 System.out.println(s);
  26.             }
  27.            
  28.            
  29.             firstN.add(parts[1]);
  30.             lastN.add(parts[2]);
  31.             city.add(parts[4]);
  32.             phone.add(parts[7]);
  33.             lastId.add(parts[8]);
  34.  
  35.             if(Integer.parseInt(parts[9]) == 1) {
  36.                 voteCount++;
  37.             }
  38.            
  39.             if(Integer.parseInt(parts[10]) == 1) {
  40.                 voteCount++;
  41.             }
  42.            
  43.             if(Integer.parseInt(parts[11]) == 1) {
  44.                 voteCount++;
  45.             }
  46.            
  47.             if(Integer.parseInt(parts[12]) == 1) {
  48.                 voteCount++;
  49.             }
  50.            
  51.             if(Integer.parseInt(parts[13]) == 1) {
  52.                 voteCount++;
  53.             }
  54.            
  55.             if(Integer.parseInt(parts[14]) == 1) {
  56.                 voteCount++;
  57.             }
  58.            
  59.             if(Integer.parseInt(parts[15]) == 1) {
  60.                 voteCount++;
  61.             }
  62.            
  63.             if(Integer.parseInt(parts[16]) == 1) {
  64.                 voteCount++;
  65.             }
  66.             votingHistory.add(Integer.toString(voteCount));
  67.  
  68.  
  69.         }
  70.        
  71.        
  72.        
  73.        
  74.         for(int i = 0; i < lineCount; i++) {
  75.             System.out.print(firstN.get(i));
  76.             System.out.print(lastN.get(i));
  77.             System.out.print(city.get(i));
  78.             System.out.print(phone.get(i));
  79.             System.out.print(lastId.get(i));
  80.             System.out.println(votingHistory.get(i));
  81.  
  82.         }
  83.  
  84.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement