public static void encode(InputStream in,Writer out) throws IOException {
  int column=0;
  while (true) {
    int byte1=in.read();
    int byte2=in.read();
    int byte3=in.read();
    if (byte1 < 0) {
      return;
    }
    if (column >= 72) {
      column=0;
      out.write('\n');
    }
    out.write(charset[byte1 >> 2]);
    int index=(byte1 & 0x3) << 4;
    if (byte2 < 0) {
      out.write(charset[index]);
      out.write(paddingChar);
      out.write(paddingChar);
      return;
    }
    index+=byte2 >> 4;
    out.write(charset[index]);
    index=(byte2 & 0xf) << 2;
    if (byte3 < 0) {
      out.write(charset[index]);
      out.write(paddingChar);
      return;
    }
    index+=byte3 >> 6;
    out.write(charset[index]);
    out.write(charset[byte3 & 0x3f]);
    column+=4;
  }
}

public static void encode ( InputStream in , Writer out ) throws IOException { int column = 0 ; while ( true ) { int byte1 = in . read ( ) ; int byte2 = in . read ( ) ; int byte3 = in . read ( ) ; if ( byte1 < 0 ) { return ; } if ( column >= 72 ) { column = 0 ; out . write ( '\n' ) ; } out . write ( charset [ byte1 > > 2 ] ) ; int index = ( byte1 & 0x3 ) << 4 ; if ( byte2 < 0 ) { out . write ( charset [ index ] ) ; out . write ( paddingChar ) ; out . write ( paddingChar ) ; return ; } index += byte2 > > 4 ; out . write ( charset [ index ] ) ; index = ( byte2 & 0xf ) << 2 ; if ( byte3 < 0 ) { out . write ( charset [ index ] ) ; out . write ( paddingChar ) ; return ; } index += byte3 > > 6 ; out . write ( charset [ index ] ) ; out . write ( charset [ byte3 & 0x3f ] ) ; column += 4 ; } }
description of the method
