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

Method urlExists

output/java8/1.4.17/Misc.java:170–197  ·  view source on GitHub ↗
(URL url)

Source from the content-addressed store, hash-verified

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

Callers 1

importTemplatesMethod · 0.95

Calls 2

closeMethod · 0.45
openStreamMethod · 0.45

Tested by

no test coverage detected