code: public static String encode(String str)
      {
          String encoded;
          try {
              encoded = URLEncoder.encode(str, "UTF-8").replace(".", "%2E").replace("*", "%2A");
          } catch (UnsupportedEncodingException e) {
              // Should never happen
  
              encoded = str;
          }
  
          return encoded;
      }
docs: Protect passed String to work with as much filesystems as possible.
  
  @param str the file or directory name to encode
  @return the encoded name
  @since 7.1RC1