pipiz.util.UrlUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Buggy Show documentation
Show all versions of Buggy Show documentation
Web crawler - easy for use
The newest version!
package pipiz.util;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
public class UrlUtils {
public static URI convertToUri(String s) {
if (s == null || s.isEmpty()) {
return null;
}
URI uri = null;
try {
uri = URI.create(s);
} catch (IllegalArgumentException e) {
try {
URL url = new URL(s);
uri = new URI(url.getProtocol(), url.getHost(), url.getPath(), url.getQuery(), null);
} catch (MalformedURLException | URISyntaxException e1) {
e1.printStackTrace();
}
}
return uri;
}
}