/** * Uses ClassLoader which loaded Streams.class to obtain resource * * @return an InputStream * @throws MissingResourceException */ public InputStream getResourceAsStream(String name) { return getResourceAsStream(getClass(), name); }
/** * Uses ClassLoader which loaded Streams.class to obtain resource * * @return an InputStream * @throws MissingResourceException */ public InputStream getResourceAsStream(String name) { ClassLoader classLoader = getClass().getClassLoader(); return getResourceAsStream(classLoader, name); }
/** * Uses ClassLoader which loaded Streams.class to obtain resource * * @return an InputStream * @throws MissingResourceException */ public InputStream getResourceAsStream(String name) { ClassLoader classLoader = getClass().getClassLoader(); return getResourceAsStream(classLoader, name); }
public Properties loadProperties(String resourceName, PrintStream err) { final InputStream is = getResourceAsStream(resourceName); Properties props = new Properties(); try { props.load(is); } catch (IOException e) { e.printStackTrace(err); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(err); } } return props; } }
private void expandResourceJarInner(File outputDir, String jarResourceName) throws IOException { InputStream is = getResourceAsStream(jarResourceName); try { JarInputStream jis = new JarInputStream(is); try { expandEachEntry(outputDir, jis); } finally { jis.close(); } } finally { is.close(); } }
public void inner() throws Exception { InputStream is = getResourceAsStream(resourceName); try { FileOutputStream fos = new FileOutputStream(file); try { copy(is, fos); } finally { fos.close(); } } finally { is.close(); } } };
private void expandResourceJarInner(File outputDir, String jarResourceName) throws IOException { InputStream is = getResourceAsStream(jarResourceName); try { JarInputStream jis = new JarInputStream(is); try { expandEachEntry(outputDir, jis); } finally { jis.close(); } } finally { is.close(); } }
public void inner() throws Exception { InputStream is = getResourceAsStream(resourceName); try { FileOutputStream fos = new FileOutputStream(file); try { copy(is, fos); } finally { fos.close(); } } finally { is.close(); } } };
private void expandResourceJarInner(File outputDir, String jarResourceName) throws IOException { InputStream is = getResourceAsStream(jarResourceName); try { JarInputStream jis = new JarInputStream(is); try { expandEachEntry(outputDir, jis); } finally { jis.close(); } } finally { is.close(); } }
@Override public void inner() throws Exception { InputStream is = getResourceAsStream(resourceName); try { FileOutputStream fos = new FileOutputStream(file); try { copy(is, fos); } finally { fos.close(); } } finally { is.close(); } } };
public String getSystemPropertyWithDefaultFromResource(String property, String resourceName, PrintStream err) { String fileVal = null; Properties props = new Properties(); final InputStream is = getResourceAsStream(resourceName); if (is != null) { try { props.load(is); fileVal = (String) props.get(property); } catch (IOException e) { e.printStackTrace(err); } finally { try { is.close(); } catch (IOException e) { e.printStackTrace(err); } } } return System.getProperty(property, fileVal); } }