Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • BufferedInputStream in java

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 423
    Answer it

    How internally BufferedInputStream work in java?
    During read from a file, how or who bring bytes from the file to the internal buffer?
    Wether BufferedInputStream read 1 byte at a time from internal buffer?

 1 Answer(s)

  • public native int read() throws IOException;
    

    This is a native call to the OS which uses the disk to read the single byte. This is a heavy operation.

    For BufferedInputStream, the method delegates to an overloaded read() method that reads 8192 amount of bytes and buffers them until they are needed. It still returns only the single byte (but keeps the others in reserve). This way the BufferedInputStream makes less native calls to the OS to read from the file.

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: