Code example for File

Methods: length

0
    public JsonFileParser(final File file) {
        parseFile(file);
    } 
 
    private void parseFile(final File file) {
        final byte[] buffer = new byte[(int) file.length()];
        DataInputStream in = null;
        String result = null;
        try { 
            in = new DataInputStream(new FileInputStream(file));
            in.readFully(buffer);
            result = new String(buffer);
        } catch (Exception e) {
            e.printStackTrace();
        } finally { 
            try { 
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            } 
Connect your IDE to all the code out there  Get Codota for Java