private JarJarURLConnection(URL url) throws IOException { super(url); final String file = url.getFile(); URL inner = new URL(file); // this is same as // connection = inner.openConnection() // we just cache the connection in URLJarCollector // because we need to be able to close it to release jar files connection = URLJarCollector.openConnection(inner); }
private void htmlURLFromPropertiesURL() { try { htmlURL = new URL(itemUrl.toString().replaceAll("\\.team", ".html")); // test that html file exists final URLConnection conn = URLJarCollector.openConnection(htmlURL); conn.getInputStream().close(); } catch (IOException ignored) { // doesn't exist htmlURL = null; } }
private boolean isInvalidURL(URL url) { if (url != null) { InputStream is = null; try { URLConnection conn = URLJarCollector.openConnection(url); is = conn.getInputStream(); return false; } catch (IOException e) { return true; } finally { FileUtil.cleanupStream(is); } } return true; }
private boolean loadProperties() { if (!isPropertiesLoaded && propertiesURL != null) { InputStream ios = null; try { URLConnection con = URLJarCollector.openConnection(propertiesURL); ios = con.getInputStream(); properties.load(ios); isPropertiesLoaded = true; return true; } catch (IOException e) { return false; } finally { FileUtil.cleanupStream(ios); } } return false; }
private boolean loadProperties() { if (itemUrl != null) { InputStream ios = null; try { final URLConnection connection = URLJarCollector.openConnection(itemUrl); ios = connection.getInputStream(); properties.load(ios); return true; } catch (IOException e) { Logger.logError(e); } finally { FileUtil.cleanupStream(ios); } } return false; }
URLConnection connection = URLJarCollector.openConnection(url);
private void visitItems(List<IRepositoryItem> repositoryItems) { String root = jarPath; InputStream is = null; BufferedInputStream bis = null; JarInputStream jarIS = null; try { URLConnection con = URLJarCollector.openConnection(rootURL); is = con.getInputStream(); bis = new BufferedInputStream(is); jarIS = new JarInputStream(bis); readJarStream(repositoryItems, root, jarIS); } catch (Exception e) { Logger.logError(rootURL + " is probably corrupted (" + e.getClass().getName() + " " + e.getMessage() + ")"); } finally { FileUtil.cleanupStream(jarIS); FileUtil.cleanupStream(bis); FileUtil.cleanupStream(is); } }
public static void extractJar(URL url) { File dest = FileUtil.getRobotsDir(); InputStream is = null; BufferedInputStream bis = null; JarInputStream jarIS = null; try { final URLConnection con = URLJarCollector.openConnection(url); is = con.getInputStream(); bis = new BufferedInputStream(is); jarIS = new JarInputStream(bis); JarEntry entry = jarIS.getNextJarEntry(); while (entry != null) { if (entry.isDirectory()) { File dir = new File(dest, entry.getName()); if (!dir.exists() && !dir.mkdirs()) { Logger.logError("Cannot create dir: " + dir); } } else { extractFile(dest, jarIS, entry); } entry = jarIS.getNextJarEntry(); } } catch (IOException e) { Logger.logError(e); } finally { FileUtil.cleanupStream(jarIS); FileUtil.cleanupStream(bis); FileUtil.cleanupStream(is); } }