Code example for DataOutput

Methods: writeInt, writeLong, writeUTF

0
     
    public static class StreamStatusSerializer implements ICompactSerializer<StreamStatus> 
    { 
        public void serialize(StreamStatus streamStatus, DataOutput dos) throws IOException
        { 
            dos.writeUTF(streamStatus.getFile());
            dos.writeLong(streamStatus.getExpectedBytes());
            dos.writeInt(streamStatus.getAction().ordinal());
        } 
         
        public StreamStatus deserialize(DataInputStream dis) throws IOException
        { 
            String targetFile = dis.readUTF();
            long expectedBytes = dis.readLong();
            StreamStatus streamStatus = new StreamStatus(targetFile, expectedBytes);
             
            int ordinal = dis.readInt();                        
            if ( ordinal == StreamCompletionAction.DELETE.ordinal() )
            { 
                streamStatus.setAction(StreamCompletionAction.DELETE);
            }