Hi all! I'm SUPER new to Java, and pretty new to programming in general, so please forgive my awful coding. I'm practicing! I have to write a program that uses Scanner to lines in from a text file and use MatchResult to see if the lines match the regex. Basically, I need it to read random inputs, such as $5665% or 4445a and weed out only the ones the have exactly 5 word characters (A-Z a-z 1-9)...no special characters. This is what I have so far, but I can't play around with my regular expression because I seem to have some hideous syntax errors. I am using Eclipse and this is what its says:
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error, insert "Finally" to complete BlockStatements
Syntax error, insert "}" to complete MethodBody
at ByteMonitor.main(ByteMonitor.java:40)
I must be missing a curly brace, and on which block to put the Finally???
Code:import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
import java.util.regex.*;
public class ByteMonitor {
public static void main(String[] args) {
try {
BufferedReader inputFile = new BufferedReader(new FileReader("input.txt"));
String line = null; //corresponds to a string in the file
while((line = inputFile.readLine()) != null){ ; //while there are lines left in the input file.
Scanner scan = new Scanner(line);
scan.findInLine ("(.*)(\\w {3})(.*)"); //find word or number characters of the length of 5
MatchResult result = scan.match();
if ( scan.hasNext() ){
String name = scan.next();
String value = scan.next();
System.out.println ("OK") ;
}
else {
System.out.println("FAIL");
}
scan.close();
}
//file I/O can potentially generate a FileNotFoundException if the specified file
//does not exist, and therefore must implement exception handling syntax
}catch (IOException e) { System.err.println("Error With File");}

