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