Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void generatePhoneList(String file) throws FileNotFoundException {
- int lineCount = 0;
- List<String> firstN = new ArrayList<String>();
- List<String> lastN = new ArrayList<String>();
- List<String> city = new ArrayList<String>();
- List<String> phone = new ArrayList<String>();
- List<String> lastId = new ArrayList<String>();
- List<String> votingHistory = new ArrayList<String>();
- Scanner scanner = new Scanner(new File(file + ".txt"));
- PrintWriter writer = new PrintWriter(file + "_PL.txt");
- while(scanner.hasNextLine()) {
- int voteCount = 0;
- lineCount++;
- String[] parts = scanner.nextLine().split("|");
- for(String s : parts) {
- System.out.println(s);
- }
- firstN.add(parts[1]);
- lastN.add(parts[2]);
- city.add(parts[4]);
- phone.add(parts[7]);
- lastId.add(parts[8]);
- if(Integer.parseInt(parts[9]) == 1) {
- voteCount++;
- }
- if(Integer.parseInt(parts[10]) == 1) {
- voteCount++;
- }
- if(Integer.parseInt(parts[11]) == 1) {
- voteCount++;
- }
- if(Integer.parseInt(parts[12]) == 1) {
- voteCount++;
- }
- if(Integer.parseInt(parts[13]) == 1) {
- voteCount++;
- }
- if(Integer.parseInt(parts[14]) == 1) {
- voteCount++;
- }
- if(Integer.parseInt(parts[15]) == 1) {
- voteCount++;
- }
- if(Integer.parseInt(parts[16]) == 1) {
- voteCount++;
- }
- votingHistory.add(Integer.toString(voteCount));
- }
- for(int i = 0; i < lineCount; i++) {
- System.out.print(firstN.get(i));
- System.out.print(lastN.get(i));
- System.out.print(city.get(i));
- System.out.print(phone.get(i));
- System.out.print(lastId.get(i));
- System.out.println(votingHistory.get(i));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement