List of usage examples for org.apache.commons.validator.routines UrlValidator ALLOW_2_SLASHES
long ALLOW_2_SLASHES
To view the source code for org.apache.commons.validator.routines UrlValidator ALLOW_2_SLASHES.
Click Source Link
From source file:org.orcid.frontend.web.forms.validate.OrcidUrlValidator.java
public OrcidUrlValidator(String[] urlValschemes) { super(urlValschemes, UrlValidator.ALLOW_2_SLASHES); }
From source file:url.DomainPathFile.java
public void createDomainPathFile(String inputFile, String domainFile, String domainPathFile) { BufferedReader br = null;/*from ww w .j av a2 s . c o m*/ PrintWriter domainwriter = null, pathwriter = null; String line = ""; UrlValidator defaultValidator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES); try { br = new BufferedReader(new FileReader(inputFile)); domainwriter = new PrintWriter(domainFile, "UTF-8"); pathwriter = new PrintWriter(domainPathFile, "UTF-8"); while ((line = br.readLine()) != null) { if (defaultValidator.isValid(line)) { java.net.URL host_path = new java.net.URL(line); String host = host_path.getHost(); String path = host_path.getPath(); domainwriter.println(host); pathwriter.println(host + path); } } domainwriter.close(); pathwriter.close(); System.out.println("Write to file-->" + domainFile + " File: " + domainPathFile); } catch (Exception e) { System.out.println(e); } System.out.println("Done"); }
From source file:url.DomainPathSeperation.java
public void getUrlDomainPath(String inputFile, String domainFile, String domainPathFile) { BufferedReader br = null;//from w w w . ja va2 s . c om PrintWriter domainwriter = null, pathwriter = null; String line = ""; UrlValidator defaultValidator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES); try { br = new BufferedReader(new FileReader(inputFile)); domainwriter = new PrintWriter(domainFile, "UTF-8"); pathwriter = new PrintWriter(domainPathFile, "UTF-8"); while ((line = br.readLine()) != null) { if (defaultValidator.isValid(line)) { URL host_path = new URL(line); String host = host_path.getHost(); String path = host_path.getPath(); domainwriter.println(host); pathwriter.println(host + path); } } domainwriter.close(); pathwriter.close(); System.out.println("Write to file-->" + domainFile + "domain+path File: " + domainPathFile); } catch (Exception e) { System.out.println(e); } System.out.println("Done"); }
From source file:url.Path.java
public String reverseDomains(String str) { String revDomain = ""; try {/*w w w . j a va 2 s . c o m*/ UrlValidator defaultValidator = new UrlValidator(UrlValidator.ALLOW_2_SLASHES); //System.out.println("URL: "+str); if (defaultValidator.isValid("http://" + str)) { URL host_path = new URL("http://" + str); String host = host_path.getHost().toLowerCase(); host = host.replace(",", ""); String path = host_path.getPath(); String out[] = host.split("\\."); boolean www = false; // System.out.println("Host: "+host); // System.out.println("Path: "+path); for (int j = out.length - 1; j >= 0; j--) { if (out[j].trim().equals("WWW") || out[j].trim().equals("www")) { www = true; } else { revDomain += "\"" + out[j] + "\"" + "#"; } } if (revDomain.endsWith("#")) { revDomain = revDomain.substring(0, revDomain.length() - 1); } //System.out.println("Host reverse: "+revDomain); if (www) { revDomain += "#" + "\"" + "www" + "\""; www = false; } revDomain += ":"; String path_split[] = path.split("[/]"); //System.out.println("Path Split: "+ Arrays.toString(path_split)); for (int i = 1; i < path_split.length; i++) { revDomain += "\"" + path_split[i].replace(",", "") + "\"" + "#"; } if (revDomain.endsWith("#")) { revDomain = revDomain.substring(0, revDomain.length() - 1); } //System.out.println("URL: "+str); //System.out.println("reverse URL: "+revDomain); } else { System.out.println("Not valid: " + str); } } catch (MalformedURLException ex) { //Logger.getLogger(URLprocess_path.class.getName()).log(Level.SEVERE, null, ex); } return revDomain; }