#fixed code
                                public static int[][] readFile(String file) {

        int[][] problem = null; // The problem matrix
        int r = 0;
        int c = 0;

        System.out.println("readFile(" + file + ")");
        int lineCount = 0;

        try {

            BufferedReader inr = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));

            String str;
            while ((str = inr.readLine()) != null && str.length() > 0) {

                str = str.trim();

                // ignore comments
                if (str.startsWith("#") || str.startsWith("%")) {
                    continue;
                }

                System.out.println(str);
                if (lineCount == 0) {
                    r = Integer.parseInt(str); // number of rows
                } else if (lineCount == 1) {
                    c = Integer.parseInt(str); // number of columns
                    problem = new int[r][c];
                } else {
                    // the problem matrix
                    String row[] = str.split("");
                    for (int j = 1; j <= c; j++) {
                        String s = row[j];
                        if (s.equals(".")) {
                            problem[lineCount - 2][j - 1] = -1;
                        } else {
                            problem[lineCount - 2][j - 1] = Integer.parseInt(s);
                        }
                    }
                }

                lineCount++;

            } // end while

            inr.close();

        } catch (IOException e) {
            System.out.println(e);
        }

        return problem;

    }
#vulnerable code 
                                public static int[][] readFile(String file) {

        int[][] problem = null; // The problem matrix
        int r = 0;
        int c = 0;

        System.out.println("readFile(" + file + ")");
        int lineCount = 0;

        try {

            BufferedReader inr = new BufferedReader(new FileReader(file));
            String str;
            while ((str = inr.readLine()) != null && str.length() > 0) {

                str = str.trim();

                // ignore comments
                if (str.startsWith("#") || str.startsWith("%")) {
                    continue;
                }

                System.out.println(str);
                if (lineCount == 0) {
                    r = Integer.parseInt(str); // number of rows
                } else if (lineCount == 1) {
                    c = Integer.parseInt(str); // number of columns
                    problem = new int[r][c];
                } else {
                    // the problem matrix
                    String row[] = str.split("");
                    for (int j = 1; j <= c; j++) {
                        String s = row[j];
                        if (s.equals(".")) {
                            problem[lineCount - 2][j - 1] = -1;
                        } else {
                            problem[lineCount - 2][j - 1] = Integer.parseInt(s);
                        }
                    }
                }

                lineCount++;

            } // end while

            inr.close();

        } catch (IOException e) {
            System.out.println(e);
        }

        return problem;

    } 
                            #location 48 
                            #vulnerability type RESOURCE_LEAK