Code example for FileInputStream

Methods: closeread

0
    public byte[] read(File file) throws IOException {
 
        byte[] buffer = new byte[(int) file.length()];
        InputStream ios = null;
        try { 
            ios = new FileInputStream(file);
            if (ios.read(buffer) == -1) {
                throw new IOException(
                        "EOF reached while trying to read the whole file"); 
            } 
        } finally { 
            try { 
                if (ios != null)
                    ios.close();
            } catch (IOException e) {
            } 
        } 
 
        return buffer;
    } 
Stop searching for code, let great code find you!  Add Codota to your java IDE