I’m testing some java code I’m working on for a school project and I’m unable to create a new file representing a txt file but am able to make one for an .m3u file. For example, the following throws a FileNotFound exception:
java.io.FileInputStream inputFile;
try
{
File file = new File("consoledata1.txt");
inputFile = new FileInputStream( file );
MixTapeConsole mtc = new MixTapeConsole(inputFile);
}
catch( Exception ex)
{
System.out.println("Could not find file");
fail("File not found.");
}
But this does not:
MixTapeModel mtm = new MixTapeModel();
mtm.loadM3U( new java.io.File("MilesDavis.m3u"));
Both files are in the file directory and confirmed (by printing the absolute path) that java is looking in the correct place for both. Any ideas would be much appreciated.
Getting an absolute path for a file does not mean it exists! E.G.
Source
Output
Conclusion
The file is either not where you think it is, or not spelled with the correct case.