Java Utililty Methods BufferedInputStream Create

List of utility methods to do BufferedInputStream Create

Description

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

Method

InputStreamgetStream(String resource)
Retrieves a resource using the current context classloader.
return new BufferedInputStream(
        Thread.currentThread().getContextClassLoader().getResourceAsStream(resource));
InputStreamgetStream(String string)
Gets a stream for the given string.
try {
    return new ByteArrayInputStream(string.getBytes("UTF-8"));
} catch (UnsupportedEncodingException wontHappen) {
    throw new RuntimeException(wontHappen);
InputStreamgetStream(String string, String codePage)
get Stream
return new ByteArrayInputStream(string.getBytes(codePage));
InputStreamgetStreamFromString(String text)
get Stream From String
try {
    byte[] bytes = text.getBytes("UTF-8");
    return new ByteArrayInputStream(bytes);
} catch (Exception e) {
    throw new AssertionError(e);
BufferedInputStreaminputStreamBuffered(final File file)
Open a buffered InputStream , equivalent to:
new BufferedInputStream(new FileInputStream(file));
BufferedInputStream input = new BufferedInputStream(new FileInputStream(file));
return input;
InputStreamtoBufferedInputStream(InputStream inputStream)
to Buffered Input Stream
if (!(inputStream instanceof BufferedInputStream)) {
    inputStream = new BufferedInputStream(inputStream);
return inputStream;
InputStreamtoBufferedInputStream(InputStream stream)
to Buffered Input Stream
if (stream instanceof BufferedInputStream) {
    return stream;
} else {
    return new BufferedInputStream(stream, DEFAULT_READING_SIZE);