Having some trouble with some code, if I put the file somewhere and then type in the full file location, it works fine, but I don't want it to be that way. I just want my data.txt to be read from the current directory.
Error is: java.io.FileNotFoundException: data.txt (The system cannot find the file specified)
I'm using Eclipse, I've tried putting data.txt in the root folder for the project, the src and bin folder, nothing works. Even tried creating the file from scratch as a part of the Eclipse project. Still won't read as data.txt. This has to be some stupid mistake I'm making, because it works with the full file location typed out, but that kills any portability.
Here's the excerpt of the code.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
//... more code
Scanner fileScanner=null;
double salary;
double commission;
double sales;
double stock;
try
{
fileScanner=new Scanner(new File("data.txt"));
while(fileScanner.hasNextLine())
{
int year=fileScanner.nextInt();
String type=fileScanner.next();
I'm trying to avoid posting all of the code because it's long, but if it's needed, please ask and I'll update.
Thanks!