List of utility methods to do InputStream Create
InputStream | toInputStream(byte[] data) converts the byte array to an input stream ByteArrayInputStream bais = new ByteArrayInputStream(data); InputStream isContent = new BufferedInputStream(bais); return isContent; |
InputStream | toInputStream(CharSequence input) Convert the specified CharSequence to an input stream, encoded as bytes using the default character encoding of the platform. return toInputStream(input.toString());
|
InputStream | toInputStream(CharSequence input, String encoding) Convert the specified CharSequence to an input stream, encoded as bytes using the specified character encoding. return toInputStream(input.toString(), encoding);
|
InputStream | toInputStream(CharSequence input, String encoding) Convert the specified CharSequence to an input stream, encoded as bytes using the specified character encoding. return toInputStream(input.toString(), encoding);
|
InputStream | toInputStream(File file) to Input Stream return new FileInputStream(file); |
InputStream | toInputStream(File file) to Input Stream InputStream in = new FileInputStream(file); if (file.getName().endsWith(".gz")) { in = new GZIPInputStream(in); return in; |
InputStream | toInputStream(final String content) Convert a string into an input stream. try { return toInputStream(content, DEFAULT_CHARSET); } catch (final UnsupportedEncodingException e) { throw new IllegalStateException(DEFAULT_CHARSET + " is an unsupported encoding! You may have a corrupted installation of java."); |
InputStream | toInputStream(final String input, final String encoding) Convert the specified string to an input stream, encoded as bytes using the specified character encoding. final byte[] bytes = encoding != null ? input.getBytes(encoding) : input.getBytes(); return new ByteArrayInputStream(bytes); |
InputStream | toInputStream(OutputStream out) OutputStream -> InputStream ByteArrayInputStream result = null; if (out instanceof ByteArrayOutputStream) { try { result = new ByteArrayInputStream(((ByteArrayOutputStream) out).toByteArray()); } catch (Exception ex) { ex.printStackTrace(); return result; |
InputStream | toInputStream(String input) to Input Stream byte[] bytes = input.getBytes(); return new ByteArrayInputStream(bytes); |