public void read() throws IOException { int i; int count = 0; byte[] packet = new byte[30]; while ((i = in.read()) != -1) { if (count == 30) { System.out.println(); count = 0; listener.packetReceived(packet); } System.out.print(Hex.toHex(i) + " "); packet[count] = (byte) i; count++; } }