(URL url)
| 172 | } |
| 173 | |
| 174 | public static boolean urlExists(URL url) { |
| 175 | try { |
| 176 | URLConnection connection = url.openConnection(); |
| 177 | if ( connection instanceof JarURLConnection ) { |
| 178 | JarURLConnection jarURLConnection = (JarURLConnection)connection; |
| 179 | URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { |
| 180 | jarURLConnection.getJarFileURL()}); |
| 181 | try { |
| 182 | return urlClassLoader.findResource(jarURLConnection.getEntryName())!=null; |
| 183 | } |
| 184 | finally { |
| 185 | if ( urlClassLoader instanceof Closeable ) { |
| 186 | ((Closeable)urlClassLoader).close(); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | InputStream is = null; |
| 191 | try { |
| 192 | is = url.openStream(); |
| 193 | } |
| 194 | finally { |
| 195 | if ( is!=null ) { |
| 196 | is.close(); |
| 197 | } |
| 198 | } |
| 199 | return is!=null; |
| 200 | } |
| 201 | catch (IOException ioe) { |
| 202 | return false; |
| 203 | } |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Given {@code index} into string {@code s}, compute the line and char |
no test coverage detected