public final void read(byte[] data) { ByteArrayInputStream bis = new ByteArrayInputStream(data); DataInputStream dis = new DataInputStream(bis); try { name = dis.readUTF(); down = dis.readBoolean(); dis.close(); } catch (IOException ex) { EreGeologique.EGLog.severe("Can't read packet"); } }
public final byte[] write() { ByteArrayOutputStream bos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(bos); try { dos.writeUTF(name); dos.writeBoolean(down); dos.close(); } catch (IOException ex) { EreGeologique.EGLog.severe("Can't write packet "); } return bos.toByteArray(); }