code: public void write(int b) throws IOException {
      // Take 24-bits from three octets, translate into four encoded chars
      // Break lines at 76 chars
      // If necessary, pad with 0 bits on the right at the end
      // Use = signs as padding at the end to ensure encodedLength % 4 == 0
  
      // Remove the sign bit,
      // thanks to Christian Schweingruber <chrigu@lorraine.ch>
      if (b < 0) {
        b += 256;
      }
  
      // First byte use first six bits, save last two bits
      if (charCount % 3 == 0) {
        int lookup = b >> 2;
        carryOver = b & 3; // last two bits
        out.write(chars[lookup]);
      }
      // Second byte use previous two bits and first four new bits,
      // save last four bits
      else if (charCount % 3 == 1) {
        int lookup = ((carryOver << 4) + (b >> 4)) & 63;
        carryOver = b & 15; // last four bits
        out.write(chars[lookup]);
      }
      // Third byte use previous four bits and first two new bits,
      // then use last six new bits
      else if (charCount % 3 == 2) {
        int lookup = ((carryOver << 2) + (b >> 6)) & 63;
        out.write(chars[lookup]);
        lookup = b & 63; // last six bits
        out.write(chars[lookup]);
        carryOver = 0;
      }
      charCount++;
  
      // Add newline every 76 output chars (that's 57 input chars)
      if (charCount % 57 == 0) {
        out.write('\n');
      }
    }
docs: *
  Writes the given byte to the output stream in an encoded form.
  
  @exception IOException if an I/O error occurs