code: public static String removeNullPadding(String str) {
          int idx = str.indexOf(0);
          if (idx == -1) {
              return str;
          }
          return str.substring(0, idx);
      }
docs: Strips off any null padding, if any, from the string