The list of methods to do InputStream Read are organized into topic(s).
String
getFileContent(InputStream in) Helper method to obtain the content of a source file.
String content = "";
BufferedReader inReader = new BufferedReader(new InputStreamReader(in));
while (inReader.ready()) {
String line = inReader.readLine();
content = content + line + "\n";
return content;
String
getFileContent(InputStream inputStream) get File Content
byte[] bytes = new byte[28];
try {
inputStream.read(bytes, 0, 28);
} catch (IOException e) {
throw new RuntimeException("read file content error!");
return bytesToHexString(bytes);
String
getFileContent(InputStream is) There is a much cleaner implementation of doing this, but good enough since it is only used for testing
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line = null;
StringBuffer buff = new StringBuffer();
while ((line = br.readLine()) != null) {
buff.append(line + "\n");
return buff.toString();
String
getFileContent(InputStream stream) get File Content
InputStreamReader reader = new InputStreamReader(stream);
char[] arr = new char[8 * 1024];
StringBuilder buf = new StringBuilder();
int numChars;
while ((numChars = reader.read(arr, 0, arr.length)) > 0) {
buf.append(arr, 0, numChars);
return buf.toString().intern();
...
InputStream
getInputStream(Class clazz) get Input Stream
InputStream is = null;
is = clazz.getResourceAsStream(DEFAULT_STRATEGIES_PATH);
if (is == null) {
throw new FileNotFoundException(
DEFAULT_STRATEGIES_PATH + " cannot be opened because it does not exist");
return is;
InputStream
getInputStream(Class> ownerClass, String subName, String extension) Opens an InputStream for a class-associated resource.
String localName;
if (subName == null) {
localName = ownerClass.getSimpleName() + '.' + extension;
} else {
localName = ownerClass.getSimpleName() + '_' + subName + '.' + extension;
return ownerClass.getResourceAsStream(localName);
InputStream
getInputstream(File compressedFile) Gets the compressed input stream for an image
try {
return new GZIPInputStream(new FileInputStream(compressedFile));
catch (Exception e) {
e.printStackTrace();
return null;
InputStream
getInputStream(Object caller, String name) Return an appropriate InputStream for the specified test file (which must be inside our current package.
return (caller.getClass().getResourceAsStream("/org/apache/commons/digester3/plugins/" + name));