code: public static String buildString(char[] data) {
      int count = 0;
      for (count=0; count < data.length; count++) {
        if (data[count] == 0) {
          break;
        }
      }
      return new String(data, 0, count);
    }
docs: Builds a string from a null-terminated char data.