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 fileName)
get Input Stream
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream inputStream = classloader.getResourceAsStream(fileName);
return inputStream;
InputStreamgetInputStream(String filename)
Return the contents of a file as InputStream .
String callerClass = Thread.currentThread().getStackTrace()[2].getClassName();
try {
    return Class.forName(callerClass).getResourceAsStream(filename);
} catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
InputStreamgetInputStream(String fileName)
get Input Stream
return Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
InputStreamgetInputStream(String filename)
Gets an input stream
File f = new File(filename);
return getInputStream(f);
InputStreamgetInputStream(String filePath)
get Input Stream
return new FileInputStream(filePath);
InputStreamgetInputStream(String fileType, String fileName)
get Input Stream
return getInputStream(fileType, new File(fileName));
InputStreamReadergetInputStream(String fname, String enc)
Getting an input stream from a file....
return new InputStreamReader(new FileInputStream(fname), enc);
InputStreamgetInputStream(String inputFile)
get Input Stream
if (inputFile.endsWith(".gz")) {
    return new GZIPInputStream(new FileInputStream(inputFile));
} else if (inputFile.equals("stdin")) {
    return System.in;
} else {
    return new FileInputStream(inputFile);
InputStreamgetInputStream(String location)
get Input Stream
InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(location);
if (inputStream == null) {
    throw new RuntimeException("File not found in classpath: " + location);
return inputStream;
InputStreamgetInputStream(String parentFolder, String fileName)
get Input Stream
File file = new File(parentFolder, fileName);
InputStream input = new FileInputStream(file);
return input;