public static final void toByteArray(ByteArrayOutputStream output,String str){
  if (str == null) {
    return;
  }
  output.write(34);
  int max=str.length();
  for (int i=0; i < max; i++) {
    int b=str.charAt(i);
    if ((b >= 32) && (b <= 126)) {
switch (b) {
case 34:
case 92:
        output.write(92);
      break;
  }
  output.write(b);
}
 else {
  output.write(92);
switch (b) {
case 8:
    output.write(98);
  break;
case 9:
output.write(116);
break;
case 10:
output.write(110);
break;
case 12:
output.write(102);
break;
case 13:
output.write(114);
break;
default :
output.write(117);
int b3=b >> 4;
int b4=b & 0xf;
if (b4 < 10) b4+=48;
 else b4+=87;
int b2=b3 >> 4;
b3&=0xf;
if (b3 < 10) b3+=48;
 else b3+=87;
int b1=b2 >> 4;
b2&=0xf;
if (b2 < 10) b2+=48;
 else b2+=87;
if (b1 < 10) b1+=48;
 else b1+=87;
output.write(b1);
output.write(b2);
output.write(b3);
output.write(b4);
break;
}
}
}
output.write(34);
}

public static final void toByteArray ( ByteArrayOutputStream output , String str ) { if ( str == null ) { return ; } output . write ( 34 ) ; int max = str . length ( ) ; for ( int i = 0 ; i < max ; i ++ ) { int b = str . charAt ( i ) ; if ( ( b >= 32 ) && ( b <= 126 ) ) { switch ( b ) { case 34 : case 92 : output . write ( 92 ) ; break ; } output . write ( b ) ; } else { output . write ( 92 ) ; switch ( b ) { case 8 : output . write ( 98 ) ; break ; case 9 : output . write ( 116 ) ; break ; case 10 : output . write ( 110 ) ; break ; case 12 : output . write ( 102 ) ; break ; case 13 : output . write ( 114 ) ; break ; default : output . write ( 117 ) ; int b3 = b > > 4 ; int b4 = b & 0xf ; if ( b4 < 10 ) b4 += 48 ; else b4 += 87 ; int b2 = b3 > > 4 ; b3 &= 0xf ; if ( b3 < 10 ) b3 += 48 ; else b3 += 87 ; int b1 = b2 > > 4 ; b2 &= 0xf ; if ( b2 < 10 ) b2 += 48 ; else b2 += 87 ; if ( b1 < 10 ) b1 += 48 ; else b1 += 87 ; output . write ( b1 ) ; output . write ( b2 ) ; output . write ( b3 ) ; output . write ( b4 ) ; break ; } } } output . write ( 34 ) ; }
provides a java string literal representing the parameter string . this includes surrounding double quotes , and quoted special characters , including utf escape sequences when necessary . < p > this function works only for ascii character encoding , and assumes this is the default encoding .
