Code example for InputStreamReader

Methods: close, read, ready

0
            if (f.length() > sizeLimit) {
                throw new IOException("File " + fileName + " length " + f.length() +
                        " exceeds limit " + sizeLimit);
            } 
            char[] buffer = new char[(int) f.length()];
            reader = new InputStreamReader(new FileInputStream(f), "UTF-8");
            int charsRead = reader.read(buffer);
            // Debug check that we've exhausted the input stream (will fail e.g. if the 
            // file grew after we inspected its length). 
            assert !reader.ready();
            return charsRead < buffer.length ? Arrays.copyOfRange(buffer, 0, charsRead) : buffer;
        } finally { 
            if (reader != null) reader.close();
        } 
    } 
 
    private CommandLine() {} 
 
    private static class JavaCommandLine extends CommandLine { 
        private HashMap<String, String> mSwitches = new HashMap<String, String>();
        private ArrayList<String> mArgs = new ArrayList<String>();