I'm trying to make a tiny program that will read inputs from a file and print them out if they match a specific format which is:
Team Name : Another Team name : Score : Score
Here is what I've done so far, If you could point me in right direction I'd really appreciate it
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class Generator {
public static void main(String[] args) throws FileNotFoundException{
String file;
Scanner fileScan;
fileScan = new Scanner (new File("document.txt"));
int count = 0;
while (fileScan.hasNextLine()){
file = fileScan.nextLine();
System.out.println(file);
count++;
}
System.out.println(count+ " number of lines successfully validated");
}
}
I'd like the program to validate whether the format is valid and if it isn't do not print that line but keep count of it so I can output at the end how many lines were not validated properly.
Thanks.