code: public synchronized byte[] readBytes() throws IOException
      {
          final int dataLength = dataInputStream.readInt();
          final byte[] data = new byte[dataLength];
  
          final int dataRead = dataInputStream.read(data, 0, dataLength);
          if (dataRead != dataLength) throw new IOException("Not enough data available");
  
          return data;
      }
docs: Reads byte array into output
  @return Bytes
  @throws IOException when not enough data is available