Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void readVotesFileInfo() throws FileNotFoundException {
- Scanner scanner = new Scanner (System.in);
- System.out.println("Qual é o nome do ficheiro?");
- String fileName = scanner.nextLine();
- File f = new File(fileName);
- int nlinhas = 0;
- String[]votes = new String[Savop.MAX_DEPUTADOS];
- Scanner fInput = new Scanner(f);
- while (fInput.hasNext() && nlinhas < Savop.MAX_DEPUTADOS) {
- String line = fInput.nextLine();
- if (line.length() == 6){
- votes[nlinhas] = line.substring(line.length()-1);
- nlinhas++;
- }else{
- System.out.println("Informação incorreta na linha " + (nlinhas+1));
- }
- }
- for (int i = 0; i < nlinhas; i++){
- System.out.println(votes[i]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement