private static byte[] stringToByteArray(String str){
  if (str == null) {
    return null;
  }
  byte[] srcByte=str.getBytes();
  int srcLength=srcByte.length;
  byte[] result=new byte[srcLength + 1];
  System.arraycopy(srcByte,0,result,0,srcLength);
  result[srcLength]=0;
  return result;
}

private static byte [ ] stringToByteArray ( String str ) { if ( str == null ) { return null ; } byte [ ] srcByte = str . getBytes ( ) ; int srcLength = srcByte . length ; byte [ ] result = new byte [ srcLength + 1 ] ; System . arraycopy ( srcByte , 0 , result , 0 , srcLength ) ; result [ srcLength ] = 0 ; return result ; }
returns this java string as a null - terminated byte array
