private boolean parseMapFile(File f) {
        try {
            FileReader fr = new FileReader(f);
            int readInt = 0;
            StringBuilder sb = new StringBuilder();
            while ((readInt = fr.read()) != -1) {
                sb.append((char) readInt);
            }
            System.out.println(sb.toString());
            String mapString = sb.toString();
            String lines[] = mapString.split("\\r?\\n");
            if (lines.length < 2) {
                throw new Exception("File format error!");
            }
            String currLine = lines[0];
            String[] currArr = currLine.split(" ");
            int w = Integer.parseInt(currArr[0]);
            int h = Integer.parseInt(currArr[1]);

            data = new int[h][w];
            WIDTH = w;
            HEIGHT = h;

            currLine = lines[1];
            currLine = currLine.replace(",", "");
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {

                    char currChar = currLine.charAt(i * w + j);
                    if (currChar == 'X') {
                        data[i][j] = BLOCKED;
                    } else if (currChar == ' ') {
                        data[i][j] = CLEAR;
                    }
                }
            }

        } catch (FileNotFoundException ex) {
            Logger.getLogger(Map.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(Map.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(Map.class.getName()).log(Level.SEVERE, null, ex);
        }

        return true;
    }