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