import java.io.*; import java.util.*; public class Driver { private File mapFile = new File("map.txt"); private char[][]maze; public static void main(String[] args) { Driver d = new Driver(); } public Driver(){ loadMap(mapFile); } private void loadMap(File f){ try{ String line; int ndx=0; FileReader fReader; BufferedReader reader; fReader = new FileReader(f); reader = new BufferedReader(fReader); String[] str; line = reader.readLine(); while ( line != null ) { line = reader.readLine(); ndx++; } line = reader.readLine(); while(line != null){ reader = new BufferedReader(fReader); maze = new char [ndx][]; for(int i = 0; i < maze.length; i++) { if (line!=null) { String insert = line; for(int x = 0; x < line.length(); x++) { maze[i][x] = insert.charAt(x); } } } reader.close(); } }catch(IOException e){ System.out.println("INVALID FILE"); } } }
I have no idea where I should be opening and closing the bufferedReader, and I don't know if this will store the chars either. Thanks for the help in advance.
P.S I can't use Scanner for this portion of the program.
This post has been edited by sport10: 21 October 2010 - 12:46 PM