private static String byteArrayToString(byte[] array){
  StringBuilder result=new StringBuilder();
  for (int i=0; i < array.length - 1; i++) {
    result.append((char)array[i]);
  }
  return result.toString();
}

private static String byteArrayToString ( byte [ ] array ) { StringBuilder result = new StringBuilder ( ) ; for ( int i = 0 ; i < array . length - 1 ; i ++ ) { result . append ( ( char ) array [ i ] ) ; } return result . toString ( ) ; }
converts a null - terminated byte array to java string
