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

Method urlExists

output/java/1.4.13/Misc.java:174–204  ·  view source on GitHub ↗
(URL url)

Source from the content-addressed store, hash-verified

172 }
173
174 public static boolean urlExists(URL url) {
175 try {
176 URLConnection connection = url.openConnection();
177 if ( connection instanceof JarURLConnection ) {
178 JarURLConnection jarURLConnection = (JarURLConnection)connection;
179 URLClassLoader urlClassLoader = new URLClassLoader(new URL[] {
180jarURLConnection.getJarFileURL()});
181 try {
182 return urlClassLoader.findResource(jarURLConnection.getEntryName())!=null;
183 }
184 finally {
185 if ( urlClassLoader instanceof Closeable ) {
186 ((Closeable)urlClassLoader).close();
187 }
188 }
189 }
190 InputStream is = null;
191 try {
192 is = url.openStream();
193 }
194 finally {
195 if ( is!=null ) {
196 is.close();
197 }
198 }
199 return is!=null;
200 }
201 catch (IOException ioe) {
202 return false;
203 }
204 }
205
206 /**
207 * 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