List of utility methods to do URL Value Check
boolean | isLocalFile(URL url) is Local File try { if (url.getProtocol().equals(new File(url.getFile()).toURI().toURL().getProtocol())) { return true; } catch (Throwable throwable) { throwable.printStackTrace(); return false; ... |
boolean | isLocalFile(URL url) is Local File return url.toExternalForm().toLowerCase().startsWith("file:"); |
boolean | isLocalhost(URL url) Checks whether the given URL is a localhost address try { InetAddress address = InetAddress.getByName(url.getHost()); if (address.isAnyLocalAddress() || address.isLoopbackAddress()) { return true; try { return NetworkInterface.getByInetAddress(address) != null; } catch (SocketException e) { ... |
boolean | isLocalURL(String s) is Local URL return s != null && s.startsWith("http://localboard/"); |
boolean | isLocalURL(URL url) is Local URL String proto = url.getProtocol(); if (proto.equals("jar") || proto.equals("reference")) String spec = url.getFile(); int sepIdx = spec.indexOf(':'); if (sepIdx == -1) return false; proto = spec.substring(0, sepIdx); ... |
boolean | isLocalURL(URL url) Whether or not it's a file url. return url.toString().startsWith("file:"); |
boolean | isNewer(URL file, URL reference) is Newer if (file == null || reference == null) throw new IllegalArgumentException("null file value"); file = getFileURL(file); reference = getFileURL(reference); if (!isFile(file) && !isFile(reference)) throw new IllegalArgumentException("destination is not a file URL"); long fileLastModified = 0; long referenceLastModified = 0; ... |
boolean | isResponseCode(String url, int expectedCode) is Response Code HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); connection.setRequestMethod("GET"); connection.connect(); return connection.getResponseCode() == expectedCode; |
boolean | isResponsive(URL url) is Responsive try { HttpURLConnection httpConnection = (HttpURLConnection) url.openConnection(); httpConnection.setRequestMethod("HEAD"); httpConnection.setConnectTimeout(1000); httpConnection.setReadTimeout(1000); return httpConnection.getResponseCode() == 200; } catch (IOException ioe) { return false; ... |
boolean | isSameFile(URL u, File out) is Same File try { if (u == null || out == null) return false; return out.equals(new File(u.toURI())); } catch (Throwable e) { return false; |