So, I need to load some text files into my applet. This is the function I have to read a file into a string:
File file = new File(location);
StringBuffer contents = new StringBuffer();
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String text = null;
// repeat until all lines is read
while ((text = reader.readLine()) != null) {
contents.append(text+"\n");
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (reader != null) {
reader.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
This worked fine in eclipse, but I just switched to Intellij IDEA, and now I get this:
java.io.FileNotFoundException: oryx.vcol (The system cannot find the file specified)
I think it might be because it’s an applet. How should I read a file into a string with an applet?