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

        ArrayList<String> result = new ArrayList<String>();

        System.out.println("readFile(" + file + ")");

        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;
                }

                result.add(str);

            } // end while

            inr.close();

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

        return result.toArray(new String[result.size()]);

    } 
                            #location 27 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public static String[] readFile(String file) {

        ArrayList<String> result = new ArrayList<String>();

        System.out.println("readFile(" + file + ")");

        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;
                }

                result.add(str);

            } // end while

            inr.close();

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

        return result.toArray(new String[result.size()]);

    }