code: public static void main(String args[]) throws IOException {
          InputStream is;
          if (args.length == 0 || "=".equals(args[0])) {
              // use bundled list
              is = PublicSuffixes.class.getClassLoader().getResourceAsStream(
              "effective_tld_names.dat");
          } else {
              is = new FileInputStream(args[0]);
          }
          BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
          String regex = getTopmostAssignedSurtPrefixRegex(reader);
          IOUtils.closeQuietly(is);
          
          boolean needsClose = false;
          BufferedWriter writer;
          if (args.length >= 2) {
              // write to specified file
              writer = new BufferedWriter(new FileWriter(args[1]));
              needsClose = true;
          } else {
              // write to stdout
              writer = new BufferedWriter(new OutputStreamWriter(System.out));
          }
          writer.append(regex);
          writer.flush();
          if (needsClose) {
              writer.close();
          }
      }
docs: Utility method for dumping a regex String, based on a published public
  suffix list, which matches any SURT-form hostname up through the broadest
  'private' (assigned/sold) domain-segment. That is, for any of the
  SURT-form hostnames...
  
  com,example, com,example,www, com,example,california,www
  
  ...the regex will match 'com,example,'.
  
  @param args
  @throws IOException