private JarInputStream getEmbeddedJarInputStream(final JarURLConnection embeddedJarUrlConnection) throws IOException { final JarInputStream embeddedJarInputStream; try { final InputStream inputStream = embeddedJarUrlConnection.getInputStream(); embeddedJarInputStream = new JarInputStream(inputStream); } catch (IOException ex) { // TODO: Notify this to reporters as far as possible. System.err.println("Failed to load entry in embedded JAR: " + embeddedJarUrlConnection.toString()); ex.printStackTrace(); throw ex; } return embeddedJarInputStream; }
@Override public String toString() { return jarURLConnection.toString(); }
@Override public String toString() { return jarURLConnection.toString(); }
@Override public String toString() { return jarURLConnection.toString(); }
/** * Resolve the specified resource name with a filename which can be used * with {@link File} class. * * @param resourceName The resource name to be resolved. * @return The corresponding filename. */ public static String resolveFilenameFromResource(String resourceName) { try { URL url = FileUtils.class.getResource(resourceName); String fileName; if (url.getProtocol().equals("file")) { fileName = url.toURI().getPath(); } else if (url.getProtocol().equals("jar")) { JarURLConnection jarUrl = (JarURLConnection) url .openConnection(); fileName = jarUrl.toString(); fileName = fileName.substring(fileName.indexOf("jar:")); } else { throw new IllegalArgumentException("Not a file"); } return fileName; } catch (Exception e) { return null; } } }