The constructor java.util.Scanner(java.util.Scanner) is undefined I don't understand why it keeps saying its undefined and the NoSuchElementException says it cant be resolved to a type and the in.Close will not work either
import java.io.*;
import java.util.Scanner;
public class MatchUp
{
public static void main(String args[]){
printHeader();
readFile(args[0]);
}
//********************************************************************
public static void readFile(String filename) //Method to read file
{
try
{
File in = new File(filename);
Scanner inFile = new Scanner(inFile);
int count = 0;
while(inFile.hasNextLine()){
String line = inFile.nextLine();
String out = "";
for(int i = 0; i < line.length(); i ++){
char ch = line.charAt(i);
out = out + ch;
if(ch == '{'){
count = count + 1;
out= out + " " + count;
}
else if (ch == '}'){
out= out + " " + count;
if(count > 0){
count = count -1;
}
}
}
}
}
catch (FileNotFoundException exception){
System.out.println("File not found."); }
catch (NoSuchElementException exception) {
System.out.println("File contents invalid."); }
catch (IOException exception) {
exception.printStackTrace();
}
finally
{
in.close();
}
}