Java Utililty Methods InputStreamReader Read

List of utility methods to do InputStreamReader Read

Description

The list of methods to do InputStreamReader Read are organized into topic(s).

Method

StringreadFile(String fileName)
Reads contents of file fully and returns as string.
return readFile(fileName, "UTF-8");
StringreadFile(String fileName)
read File
return readFile(fileName, ENCODING);
StringreadFile(String fileName)
read File
FileInputStream fis = new FileInputStream(fileName);
BufferedReader in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
StringBuilder sb = new StringBuilder();
while (in.ready()) {
    String line = in.readLine();
    sb.append(line).append('\n');
in.close();
...
StringreadFile(String filename)
read File
String content = "";
File fileDirs = new File(filename);
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileDirs), "UTF-8"));
String str;
while ((str = in.readLine()) != null) {
    content = content.concat(str + System.lineSeparator());
return content;
...
StringreadFile(String filename)
Reads the given filename into a string.
return readInputStream(new FileInputStream(filename));
Stringreadfile(String filename)
readfile
StringBuilder out = new StringBuilder();
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "KOI8-R"));
char[] buf = new char[8192];
int i;
while ((i = in.read(buf, 0, buf.length)) > -1) {
    if (i > 0) {
        out.append(buf, 0, i);
in.close();
return out.toString();
ListreadFile(String fileName)
read File
List<String> rst = new ArrayList<String>();
BufferedReader br = null;
try {
    br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
    String in = null;
    while ((in = br.readLine()) != null) {
        rst.add(in);
} catch (IOException ioe) {
    throw ioe;
} finally {
    br.close();
return rst;
StringreadFile(String fileName)
read File
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-8"));
StringBuilder fin = new StringBuilder();
for (;;) {
    int cur = in.read();
    if (cur < 0)
        break;
    fin.append((char) cur);
return fin.toString();
StringreadFile(String fileName)
read File
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
try {
    br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileName))));
    String line;
    while ((line = br.readLine()) != null) {
        sb.append(line).append("\n");
} catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        if (br != null) {
            br.close();
    } catch (IOException e) {
        e.printStackTrace();
return sb.toString();
StringreadFile(String fileName)
read File
InputStream in = new FileInputStream(new File(fileName));
return readStream(in);