List of utility methods to do InputStream Create
ImageInputStream | getInputStream(final File file) Retrieves an ImageInputStream for the provided input File . final ImageInputStream inStream = ImageIO.createImageInputStream(file); if (inStream == null) return null; return inStream; |
FileInputStream | getInputStream(final File file) get Input Stream try { return new FileInputStream(file); } catch (FileNotFoundException e) { return null; |
InputStream | getInputStream(final File file, final boolean createFile) Gets the input stream from a File object. InputStream is = null; if (file.exists()) { is = file.toURI().toURL().openStream(); } else { if (createFile) { file.createNewFile(); is = file.toURI().toURL().openStream(); } else { ... |
ByteArrayInputStream | getInputStream(final Serializable obj) get Input Stream byte[] bin = getBytes(obj); return new ByteArrayInputStream(bin); |
InputStream | getInputStream(final String fileName) Get input stream for specified file name. Thread curThread = Thread.currentThread();
ClassLoader loader = curThread.getContextClassLoader();
return loader.getResourceAsStream(fileName);
|
InputStream | getInputStream(final String sourceFolder, final Class> clazz) get Input Stream return clazz.getResourceAsStream("/" + clazz.getName().replace('.', '/') + ".java"); |
InputStream | getInputStream(String content) get Input Stream try { return new ByteArrayInputStream(content.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { throw new RuntimeException("Problem generating input stream"); |
InputStream | getInputStream(String data) returns an input stream that will give you back the specified string final String theData = data; return new InputStream() { final String data = theData; int position = 0; public int read() throws EOFException { if (position < data.length()) return data.charAt(position++); return -1; ... |
java.io.InputStream | getInputStream(String filename) get Input Stream File file = null; FileInputStream fin = null; try { file = new File(filename); if (file != null && file.isFile()) { fin = new FileInputStream(file); return fin; return null; } catch (IOException ex) { fin = null; throw new RuntimeException(ex); |
InputStream | getInputStream(String fileName) get Input Stream return new FileInputStream(fileName); |