@Test public void toByteArrayAndBack() throws Exception { byte[] arrayA = findCloseNodesPacket.toByteArray(); byte[] arrayB = new FindClosePeersPacket(arrayA).toByteArray(); assertArrayEquals("The two arrays differ!", arrayA, arrayB); }
@Override public byte[] toByteArray() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { writeHeader(outputStream); outputStream.write(key.toByteArray()); } catch (IOException e) { log.error("Can't write to ByteArrayOutputStream.", e); } return outputStream.toByteArray(); }
FindClosePeersPacket extends CommunicationPacket { @Override public byte[] toByteArray() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { writeHeader(outputStream); outputStream.write(key.toByteArray()); } catch (IOException e) { log.error("Can't write to ByteArrayOutputStream.", e); } return outputStream.toByteArray(); } }
FindClosePeersPacket extends CommunicationPacket { @Override public byte[] toByteArray() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { writeHeader(outputStream); outputStream.write(key.toByteArray()); } catch (IOException e) { log.error("Can't write to ByteArrayOutputStream.", e); } return outputStream.toByteArray(); } FindClosePeersPacket(Hash key);  FindClosePeersPacket(byte[] data); }
FindClosePeersPacket extends CommunicationPacket { @Override public byte[] toByteArray() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { writeHeader(outputStream); outputStream.write(key.toByteArray()); } catch (IOException e) { log.error("Can't write to ByteArrayOutputStream.", e); } return outputStream.toByteArray(); } FindClosePeersPacket(Hash key);  FindClosePeersPacket(byte[] data); Hash getKey(); @Override byte[] toByteArray(); @Override String toString(); }
FindClosePeersPacket extends CommunicationPacket { @Override public byte[] toByteArray() { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); try { writeHeader(outputStream); outputStream.write(key.toByteArray()); } catch (IOException e) { log.error("Can't write to ByteArrayOutputStream.", e); } return outputStream.toByteArray(); } FindClosePeersPacket(Hash key);  FindClosePeersPacket(byte[] data); Hash getKey(); @Override byte[] toByteArray(); @Override String toString();  }