title: DataInputStream's readFully query
body: <p>I am using dataInputStream's readFully message to read a fixed length byte array as:</p>
  
  <pre><code>byte[] record = new byte[4660004];
  
  in.readFully(record);
  </code></pre>
  
  <p>The problem here is that sometimes it takes more than 5 seconds to read these many bytes, which is equal to 20000 records. And I am receiving this data on socket. Client is sending data as byte array of 4660004 bytes. Is there a way to received this data faster as right now it takes about 5 minutes to 1 million such records.</p>
  
  <p>EDIT:: complete data flow :</p>
  
  <p>first I create the stream :</p>
  
  <pre><code>static DataInputStream dIn = null;
  
  dIn = new DataInputStream(connection.getInputStream());
  msgType = dIn.readByte();
  
  int msgIntLen = dIn.readInt();
  
  processBatch(msgIntType, msgIntLen, dIn, connector);
  
  .
  .
  
  private static void processBatch(int msgIntType, int msgIntLen, DataInputStream in,
              Connector connector) throws IOException {
  
     int recordIntLen = in.readInt();
     byte[] record = new byte[msgIntLen - 4];
     in.readFully(record);
  
  }   
  </code></pre>
  
  <p>where should I include the Buffering if that wudf help ?</p>