Code example for DataInputStream

Methods: read, readInt

0
    } 
 
    @Override 
    protected void readData(byte[] data) throws IOException {
        ByteArrayInputStream bis = new ByteArrayInputStream(data);
        DataInputStream dis = new DataInputStream(bis);
        dis.read(); // Throw away the type info
        port = dis.readInt();
    } 
 
    public int getPort() { 
        return port;
    } 
 
    public void setPort(int port) {
        this.port = port;
    } 
}