MCPcopy Index your code
hub / github.com/antlr/codebuff / urlExists

Method urlExists

output/java8/1.4.13/Misc.java:172–200  ·  view source on GitHub ↗
(URL url)

Source from the content-addressed store, hash-verified

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

Callers 1

importTemplatesMethod · 0.95

Calls 2

closeMethod · 0.45
openStreamMethod · 0.45

Tested by

no test coverage detected