public void write(int symbol) throws IOException { if (codeTree == null) throw new NullPointerException("Code tree is null"); List<Integer> bits = codeTree.getCode(symbol); for (int b : bits) output.write(b); }