public static int[][] getTriangleData(String filename) {
        try {
            BufferedReader in = new BufferedReader(new FileReader(filename));
            String line;
            int lines = 0;

            while (in.readLine() != null) {
                lines++;
            }
            in.close();

            int[][] result = new int[lines][lines];
            for (int i = 0; i < lines; i++) {
                for (int j = 0; j < lines; j++) {
                    result[i][j] = 0;
                }
            }

            in = new BufferedReader(new FileReader(filename));
            int lineNum = 0;
            while ((line = in.readLine()) != null) {
                String[] lineSplit = line.split(" ");
                if (lineSplit.length > 1) {
                    for (int i = 0; i < lineSplit.length; i++)
                        result[lineNum][i] = Integer.parseInt(lineSplit[i]);
                } else {
                    result[lineNum][0] = Integer.parseInt(lineSplit[0]);
                }
                lineNum++;
            }
            in.close();
            return result;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }