Packet packet = createPacket();
System.out.println("Created packet: " + packet + " with type: " + packet.getPacketType());
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
DataOutputStream dataOut = new DataOutputStream(buffer);
wireFormat.writePacket(packet, dataOut);
dataOut.close();
byte[] bytes = buffer.toByteArray();
DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(bytes));
int type = dataIn.readByte();