public static LogMessage read(final DataInputStream inputStream) throws IOException {
  LogMessage entry=new LogMessage();
  int svclen=inputStream.read();
  if (svclen > 0) {
    byte[] svcArr=new byte[svclen];
    inputStream.readFully(svcArr);
    entry.setService(svcArr);
  }
  int fnameOffset=inputStream.readShort();
  int fnameLen=inputStream.readShort();
  entry.setFileName(fnameOffset,fnameLen);
  int tnameOffset=inputStream.readShort();
  int tnameLen=inputStream.readShort();
  entry.setThreadName(tnameOffset,tnameLen);
  entry.setLevel(inputStream.read());
  int lineNoOffset=inputStream.readShort();
  int lineNoLen=inputStream.read();
  entry.setLineNumber(lineNoOffset,lineNoLen);
  entry.setTime(inputStream.readLong());
  int timeOffset=inputStream.readShort();
  int timeLen=inputStream.read();
  entry.setTimeBytes(timeOffset,timeLen);
  entry.setLogOffset(inputStream.readShort());
  int msglen=inputStream.readInt();
  if (msglen > 0) {
    byte[] msgArr=new byte[msglen];
    inputStream.readFully(msgArr);
    entry.setFirstLine(msgArr);
  }
  return entry;
}

public static LogMessage read ( final DataInputStream inputStream ) throws IOException { LogMessage entry = new LogMessage ( ) ; int svclen = inputStream . read ( ) ; if ( svclen > 0 ) { byte [ ] svcArr = new byte [ svclen ] ; inputStream . readFully ( svcArr ) ; entry . setService ( svcArr ) ; } int fnameOffset = inputStream . readShort ( ) ; int fnameLen = inputStream . readShort ( ) ; entry . setFileName ( fnameOffset , fnameLen ) ; int tnameOffset = inputStream . readShort ( ) ; int tnameLen = inputStream . readShort ( ) ; entry . setThreadName ( tnameOffset , tnameLen ) ; entry . setLevel ( inputStream . read ( ) ) ; int lineNoOffset = inputStream . readShort ( ) ; int lineNoLen = inputStream . read ( ) ; entry . setLineNumber ( lineNoOffset , lineNoLen ) ; entry . setTime ( inputStream . readLong ( ) ) ; int timeOffset = inputStream . readShort ( ) ; int timeLen = inputStream . read ( ) ; entry . setTimeBytes ( timeOffset , timeLen ) ; entry . setLogOffset ( inputStream . readShort ( ) ) ; int msglen = inputStream . readInt ( ) ; if ( msglen > 0 ) { byte [ ] msgArr = new byte [ msglen ] ; inputStream . readFully ( msgArr ) ; entry . setFirstLine ( msgArr ) ; } return entry ; }
read object back from buffer refer to the serialization format in the write method .
