public static long getResourceLastModified(URLConnection connection) throws IOException
    {
        long modified;
        if (connection instanceof JarURLConnection)
        {
            // The following hack is required to work-around a JDK bug.
            // getLastModified() on a JAR entry URL delegates to the actual JAR file
            // rather than the JAR entry.
            // This opens internally, and does not close, an input stream to the JAR
            // file.
            // In turn, you cannot close it by yourself, because it's internal.
            // The work-around is to get the modification date of the JAR file
            // manually,
            // and then close that connection again.

            URL jarFileUrl = ((JarURLConnection) connection).getJarFileURL();
            URLConnection jarFileConnection = jarFileUrl.openConnection();

            try
            {
                modified = jarFileConnection.getLastModified();
            }
            finally
            {
                try
                {
                    jarFileConnection.getInputStream().close();
                }
                catch (Exception exception)
                {
                    // Ignored
                }
            }
        }
        else
        {
            modified = connection.getLastModified();
        }

        return modified;
    }
public static long getResourceLastModified ( URLConnection connection ) throws IOException { long modified ; if ( connection instanceof JarURLConnection ) { URL jarFileUrl = ( ( JarURLConnection ) connection ) . getJarFileURL ( ) ; URLConnection jarFileConnection = jarFileUrl . openConnection ( ) ; try { modified = jarFileConnection . getLastModified ( ) ; } finally { try { jarFileConnection . getInputStream ( ) . close ( ) ; } catch ( Exception exception ) { } } } else { modified = connection . getLastModified ( ) ; } return modified ; }
Taken from trinidad URLUtils