Java Utililty Methods InputStream Create

List of utility methods to do InputStream Create

Description

The list of methods to do InputStream Create are organized into topic(s).

Method

InputStreamgetInputStream(String path)
get Input Stream
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
if (null == is) {
    throw new FileNotFoundException(path + " cannot be opened because it does not exist");
return is;
InputStreamgetInputStream(String path)
get Input Stream
try {
    return new FileInputStream(path);
} catch (FileNotFoundException e) {
    e.printStackTrace();
return null;
InputStreamgetInputStream(String path)
get Input Stream
return new FileInputStream(path);
InputStreamgetInputStream(String sPath)
Creates an input stream from the path @sPath.
try {
    InputStream is = new FileInputStream(new File(sPath));
    return is;
} catch (FileNotFoundException ex) {
    return null;
InputStreamgetInputStream(String str)
Returns an InputStream given a String str
byte[] b = str.getBytes();
ByteArrayInputStream iStream = new ByteArrayInputStream(b);
return iStream;
InputStreamgetInputStream(String text)
get Input Stream
InputStream inputStream = new ByteArrayInputStream(text.getBytes("utf-8"));
return inputStream;
InputStreamgetInputStream(String thePath)
get Input Stream
try {
    return new FileInputStream(thePath);
} catch (FileNotFoundException ex) {
    System.err.println("### ERROR @ Util.getInputStream / couldn t create inputstream " + ex);
    return null;
InputStreamgetInputStream(String url)
return input stream from specified url
InputStream is = null;
if (url != null) {
    if (url.indexOf(File.separator) != -1) {
        byte[] infoArray = readFile(url);
        if (infoArray != null) {
            is = new ByteArrayInputStream(infoArray);
    } else {
...
InputStreamgetInputStream(String xmlStr)
get InputStream data
return new ByteArrayInputStream(xmlStr.getBytes());
InputStreamgetInputStream(String... subpaths)
get Input Stream
String path = join(File.separator, subpaths);
File file = new File(path);
return new FileInputStream(file);