int      numberLines       = (numberQuartet-1)/19;
  public static String encode(byte[] binaryData) {      if (binaryData == null)          return null;      int      lengthDataBits    = binaryData.length*EIGHTBIT;      if (lengthDataBits == 0) {          return "";      }            int      fewerThan24bits   = lengthDataBits%TWENTYFOURBITGROUP;      int      numberTriplets    = lengthDataBits/TWENTYFOURBITGROUP;      int      numberQuartet     = fewerThan24bits != 0 ? numberTriplets+1 : numberTriplets;      int      numberLines       = (numberQuartet-1)/19;      char     encodedData[]     = null;      encodedData = new char[numberQuartet*4+numberLines];      byte k=0, l=0, b1=0,b2=0,b3=0;      int encodedIndex = 0;      int dataIndex   = 0;      int i           = 0;      if (fDebug) {          System.out.println("number of triplets = " + numberTriplets );      }      for (int line = 0; line < numberLines-1; line++) {          for (int quartet = 0; quartet < 19; quartet++) {              b1 = binaryData[dataIndex++];              b2 = binaryData[dataIndex++];              b3 = binaryData[dataIndex++];              if (fDebug) {                  System.out.println( "b1= " + b1 +", b2= " + b2 + ", b3= " + b3 );              }              l  = (byte)(b2 & 0x0f);              k  = (byte)(b1 & 0x03);              byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);              byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);              byte val3 = ((b3 & SIGN)==0)?(byte)(b3>>6):(byte)((b3)>>6^0xfc);              if (fDebug) {                  System.out.println( "val2 = " + val2 );                  System.out.println( "k4   = " + (k<<4));                  System.out.println( "vak  = " + (val2 | (k<<4)));              }              encodedData[encodedIndex++] = lookUpBase64Alphabet[ val1 ];              encodedData[encodedIndex++] = lookUpBase64Alphabet[ val2 | ( k<<4 )];              encodedData[encodedIndex++] = lookUpBase64Alphabet[ (l <<2 ) | val3 ];              encodedData[encodedIndex++] = lookUpBase64Alphabet[ b3 & 0x3f ];              i++;          }          encodedData[encodedIndex++] = 0xa;      }      for (; i<numberTriplets; i++) {          b1 = binaryData[dataIndex++];          b2 = binaryData[dataIndex++];          b3 = binaryData[dataIndex++];          if (fDebug) {              System.out.println( "b1= " + b1 +", b2= " + b2 + ", b3= " + b3 );          }          l  = (byte)(b2 & 0x0f);          k  = (byte)(b1 & 0x03);          byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);          byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);          byte val3 = ((b3 & SIGN)==0)?(byte)(b3>>6):(byte)((b3)>>6^0xfc);          if (fDebug) {              System.out.println( "val2 = " + val2 );              System.out.println( "k4   = " + (k<<4));              System.out.println( "vak  = " + (val2 | (k<<4)));          }          encodedData[encodedIndex++] = lookUpBase64Alphabet[ val1 ];          encodedData[encodedIndex++] = lookUpBase64Alphabet[ val2 | ( k<<4 )];          encodedData[encodedIndex++] = lookUpBase64Alphabet[ (l <<2 ) | val3 ];          encodedData[encodedIndex++] = lookUpBase64Alphabet[ b3 & 0x3f ];      }      // form integral number of 6-bit groups      if (fewerThan24bits == EIGHTBIT) {          b1 = binaryData[dataIndex];          k = (byte) ( b1 &0x03 );          if (fDebug) {              System.out.println("b1=" + b1);              System.out.println("b1<<2 = " + (b1>>2) );          }          byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);          encodedData[encodedIndex++] = lookUpBase64Alphabet[ val1 ];          encodedData[encodedIndex++] = lookUpBase64Alphabet[ k<<4 ];          encodedData[encodedIndex++] = PAD;          encodedData[encodedIndex++] = PAD;      } else if (fewerThan24bits == SIXTEENBIT) {          b1 = binaryData[dataIndex];          b2 = binaryData[dataIndex +1 ];          l = ( byte ) ( b2 &0x0f );          k = ( byte ) ( b1 &0x03 );          byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);          byte val2 = ((b2 & SIGN)==0)?(byte)(b2>>4):(byte)((b2)>>4^0xf0);          encodedData[encodedIndex++] = lookUpBase64Alphabet[ val1 ];          encodedData[encodedIndex++] = lookUpBase64Alphabet[ val2 | ( k<<4 )];          encodedData[encodedIndex++] = lookUpBase64Alphabet[ l<<2 ];          encodedData[encodedIndex++] = PAD;      }      //encodedData[encodedIndex] = 0xa;            return new String(encodedData);  }