title: Java - Read file by chunks?
body: <p>I know how to read a file by bytes but cannot find a example how to read it in chunks of bytes. I have a byte array, and i want to read the file by 512bytes and send them over a socket.</p>
  
  <p>I have tried by reading total bytes of file and then subtracting 512 bytes until i got a chunk that was less than 512 bytes and signaled EOF and end of transfer.</p>
  
  <p>I am trying to implement a TFTP, where data is sent in 512 byte chunks.</p>
  
  <p>Anyhow would be thankful for a example.</p>