So, I need to load some text files into my applet. This is the function I have to read a file into a string:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| File file = new File(location); StringBuffer contents = new StringBuffer(); BufferedReader reader = null;
try { reader = new BufferedReader(new FileReader(file)); String text = null;
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:
1
| 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?