I've created a world that I have stored on a file on my labtop, but having a difficult time of reading that file in Greenfoot. I want this to appear in the world. Does anybody know how to do this?


public String[] readText() throws IOException { InputStream is = getClass().getClassLoader().getResourceAsStream("pars.txt"); BufferedReader r = new BufferedReader(new InputStreamReader(is)); String[] lines = new String[maxLevel-1]; for (int i = 0; i < maxLevel-1; i++) { lines[i] = r.readLine(); } return lines; } public String readText(int row) throws IOException { InputStream is = getClass().getClassLoader().getResourceAsStream("pars.txt"); BufferedReader r = new BufferedReader(new InputStreamReader(is)); String[] lines = new String[maxLevel-1]; for (int i = 0; i < maxLevel-1; i++) { lines[i] = r.readLine(); } return lines[row]; }
try { readText(3); } catch(IOException iox) { //What to do if it fails to read text }