I am literally compiling the same java file in both command line and NetBeans but I get different results. It is maddening and confusing. The code itself is simple and it is correct in command line. I get "Error" in NetBeans. This should not vary as far as I can tell...
import java.io.*;
public class A3
{
public static void main(String[] args)
{
BufferedReader fileReader = null;
try
{
fileReader = new BufferedReader(new FileReader("input.txt"));
String aLine = fileReader.readLine();
String myTokens[] = aLine.split(" ");
System.out.println("Token 1 = " + myTokens[0]);
System.out.println("Token 2 = " + myTokens[1]);
fileReader.close();
}
catch(IOException anException)
{
System.out.println("Error");
}
}
}
SOLVED! I was way overthinking things. Command line looks for the .txt file in the same directory as the .java. Which is logical. NetBeans looks in the root directory. Which is...yeah.