List of utility methods to do InputStream Create
InputStream | getInputStream(String[] args) Searches the command line args for -f path_to_file. for (int i = 0; i < args.length - 1; i++) { if ("-f".equals(args[i])) { File f = new File(args[i + 1]); if (f.exists() && f.isFile()) try { return new FileInputStream(f); } catch (FileNotFoundException e) { System.err.println("Something went horribly wrong!"); ... |
InputStream | inputStream(final File file) input Stream return file.getName().endsWith(".gz") ? new GZIPInputStream(new FileInputStream(file)) : new FileInputStream(file); |
InputStream | inputStream(final String in) Makes an input stream from a String. return new InputStream() { int charindex = 0; public synchronized int read() throws IOException { if (charindex < in.length()) { return (int) in.charAt(charindex++); } else return -1; }; |
FileInputStream | inputStream(String fileName) input Stream FileInputStream stream = null; try { stream = new FileInputStream(new File(fileName)); } catch (FileNotFoundException e) { e.printStackTrace(); return stream; |
InputStream | inputStream(String path) input Stream return new BufferedInputStream(new FileInputStream(path)); |
InputStream | inputStreamFromPath(String path) input Stream From Path try { return new BufferedInputStream(new FileInputStream(new File(path))); } catch (FileNotFoundException e) { throw new RuntimeException(e); |
InputStream | InputStreamFromString(String str) Input Stream From String byte[] bytes = null; ByteArrayInputStream thisInputStream = null; try { bytes = str.getBytes(ENCODING); thisInputStream = new ByteArrayInputStream(bytes); } catch (Exception e) { return thisInputStream; ... |
InputStream | newInputStream(Class> clazz, String filename) new Input Stream String resource = clazz.getPackage().getName().replace(".", "/") + "/" + filename; return clazz.getClassLoader().getResourceAsStream(resource); |
InputStreamReader | newInputStreamReader(InputStream is) new Input Stream Reader try { return new InputStreamReader(is, strCode); } catch (UnsupportedEncodingException e) { e.printStackTrace(); return null; |
InputStream | toInputStream(byte[] bytes) Converts an array of bytes into an Input Stream return new ByteArrayInputStream(bytes); |