Code example for BufferedReader

Methods: close, readLine

0
 
    public static String readOneLine(String fname) {
        BufferedReader br = null;
        String line = null;
        try { 
            br = new BufferedReader(new FileReader(fname), 1024);
            line = br.readLine();
        } catch (FileNotFoundException ignored) {
            Log.d(TAG, "File was not found! trying via shell...");
            return readFileViaShell(fname, true);
        } catch (IOException e) {
            Log.d(TAG, "IOException while reading system file", e);
            return readFileViaShell(fname, true);
        } finally { 
            if (br != null) {
                try { 
                    br.close();
                } catch (IOException ignored) {
                    // failed to close reader 
                } 
            } 
        }