code: public static void writeSingleByte(OutputStream out, int b) throws IOException {
          byte[] buffer = new byte[1];
          buffer[0] = (byte) (b & 0xff);
          out.write(buffer);
      }
docs: Implements OutputStream.write(int) in terms of OutputStream.write(byte[], int, int).
  OutputStream assumes that you implement OutputStream.write(int) and provides default
  implementations of the others, but often the opposite is more efficient.