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