Ejemplo n.º 1
0
 public void write(int c) throws IOException {
   inbuf[i] = c;
   i++;
   if (i == 3) {
     super.write(toBase64[(inbuf[0] & 0xFC) >> 2]);
     super.write(toBase64[((inbuf[0] & 0x03) << 4) | ((inbuf[1] & 0xF0) >> 4)]);
     super.write(toBase64[((inbuf[1] & 0x0F) << 2) | ((inbuf[2] & 0xC0) >> 6)]);
     super.write(toBase64[inbuf[2] & 0x3F]);
     col += 4;
     i = 0;
     if (col >= 76) {
       super.write('\n');
       col = 0;
     }
   }
 }
Ejemplo n.º 2
0
 public void flush() throws IOException {
   if (i == 1) {
     super.write(toBase64[(inbuf[0] & 0xFC) >> 2]);
     super.write(toBase64[(inbuf[0] & 0x03) << 4]);
     super.write('=');
     super.write('=');
   } else if (i == 2) {
     super.write(toBase64[(inbuf[0] & 0xFC) >> 2]);
     super.write(toBase64[((inbuf[0] & 0x03) << 4) | ((inbuf[1] & 0xF0) >> 4)]);
     super.write(toBase64[(inbuf[1] & 0x0F) << 2]);
     super.write('=');
   }
   if (col > 0) {
     super.write('\n');
     col = 0;
   }
 }