List of utility methods to do InputStream Read
InputStream | getInputStreamFile(String URLString) Get the InputStream from a File final String eLabel = "ResourceRequestUtils.getInputStreamFile: "; OutputStream os = null; try { File file = new File(URLString); if ((!file.exists()) || (!file.isFile())) { throw new Exception("File resource does not exist: " + URLString); return new FileInputStream(file); ... |
InputStream | getInputStreamFor(String path, Class> clazz) get Input Stream For return clazz.getClassLoader().getResourceAsStream(path);
|
InputStream | getInputStreamForFileAbsolutePath(String _path) Will check that the path is absolute and is pointing to an existing file. InputStream result = null; if (null != _path) { File file = new File(_path); if (file.exists() && file.isAbsolute() && !file.isDirectory()) { try { result = new FileInputStream(file); } catch (FileNotFoundException e) { return result; |
InputStream | getInputStreamForResource(String name) get Input Stream For Resource ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
return classLoader.getResourceAsStream(name);
|
InputStream | getInputStreamForResource(String relativePath) get Input Stream For Resource String resourcePath = null; InputStream is = null; ClassLoader loader = Thread.currentThread().getContextClassLoader(); resourcePath = relativePath.replace("\\", "/"); is = loader.getResourceAsStream(resourcePath); if (is == null) { throw new RuntimeException( "Unable to create an input stream as the following resoure was mot found from the classpath " ... |
InputStream | getInputStreamFromAbsolutePath(String resource) get Input Stream From Absolute Path try { return new FileInputStream(resource); } catch (IOException e) { return null; |
InputStream | getInputStreamFromClassPath(String filename) get Input Stream From Class Path return Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
|
InputStream | getInputStreamFromFile(File pFile) Gets an InputStream for the contents of a file - if the file is .gz it will return a stream of the decompressed contents if (!pFile.exists()) return null; try { return new GZIPInputStream(new FileInputStream(pFile)); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { try { ... |
InputStream | getInputStreamFromFile(final File file) Reads a file an returns an InputStream from it.
return new FileInputStream(file); |
InputStream | getInputStreamFromZip(ZipInputStream zis, String filename) Read file from ZIP ZipEntry zi = null; InputStream is = null; while ((zi = zis.getNextEntry()) != null) { if (filename.equals(zi.getName())) { is = zis; break; return is; |