code: private static byte[] stringToByteArray(String str) {
  		byte[] result = new byte[str.length() + 1];
  		for (int i = 0; i < str.length(); i++) {
  			result[i] = (byte) str.charAt(i);
  		}
  		result[str.length()] = 0;
  		return result;
  	}
docs: Returns this java string as a null-terminated byte array