MCPcopy Create free account
hub / github.com/antlr/codebuff / urlExists

Method urlExists

output/java/1.4.17/Misc.java:175–206  ·  view source on GitHub ↗
(URL url)

Source from the content-addressed store, hash-verified

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[]{
181jarURLConnection.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

Callers 1

importTemplatesMethod · 0.95

Calls 2

closeMethod · 0.45
openStreamMethod · 0.45

Tested by

no test coverage detected