Java URL Connection getLastModified(URL url)

Here you can find the source of getLastModified(URL url)

Description

Returns the last modified time stamp for the passed URL

License

Apache License

Parameter

Parameter Description
url The URL to get the timestamp for

Return

the last modified time stamp for the passed URL

Declaration

public static long getLastModified(URL url) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.net.URL;
import java.net.URLConnection;

public class Main {
    /**/*from   w  w w.  j  ava  2 s.c om*/
     * Returns the last modified time stamp for the passed URL
     * @param url The URL to get the timestamp for
     * @return the last modified time stamp for the passed URL
     */
    public static long getLastModified(URL url) {
        URLConnection conn = null;
        try {
            conn = nvl(url, "Passed URL was null").openConnection();
            return conn.getLastModified();
        } catch (Exception e) {
            throw new RuntimeException("Failed to get LastModified for [" + url + "]", e);
        }
    }

    public static <T> T nvl(T t, String message) {
        if (t == null)
            throw new IllegalArgumentException(message);
        return (T) t;
    }
}

Related

  1. getHttpHeaders(URLConnection connection)
  2. getHttpResponseHeader(URLConnection http)
  3. getImageFromURL(String remoteURL)
  4. getJar(String jarUrl)
  5. getJarUrlForPackage(String packageName)
  6. getLastModified(URLConnection connection)
  7. getLength(String htmlUrl)
  8. getLines(final URL url, final int linesToRead)
  9. getOutputStream(final URL outputURL)