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

String[]readFile(InputStream location)
read File
ArrayList<String> readLines = new ArrayList<>();
try (BufferedReader br = new BufferedReader(new InputStreamReader(location))) {
    String line = br.readLine();
    while (line != null) {
        readLines.add(line);
        line = br.readLine();
} catch (Exception e) {
...
voidreadFile(InputStream stream, StringBuilder builder)
read File
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
String s = "";
try {
    while ((s = br.readLine()) != null) {
        builder.append(s + "\n");
} catch (IOException e) {
    e.printStackTrace();
...
ListreadFile(Reader simpleReader)
read File
BufferedReader reader = new BufferedReader(simpleReader);
List<String> res = new ArrayList();
String line = null;
while ((line = reader.readLine()) != null) {
    res.add(line);
reader.close();
return res;
...
StringreadFile(String aFile)
Read a file into a string
BufferedReader bin = null;
StringBuilder sb = new StringBuilder();
try {
    FileInputStream is = new FileInputStream(aFile);
    bin = new BufferedReader(new InputStreamReader(is, "UTF-8"));
    String line = null;
    while ((line = bin.readLine()) != null) {
        sb.append(line);
...
StringreadFile(String f)
read File
InputStreamReader in = null;
try {
    StringBuilder sb = new StringBuilder();
    in = new InputStreamReader(new FileInputStream(f), "UTF-8");
    int count = 0;
    char[] buf = new char[1024 * 10];
    while ((count = in.read(buf, 0, buf.length)) > -1)
        sb.append(buf, 0, count);
...
String[][]readFile(String f, String delim)
read File
return readFile(f, delim, 0);
StringreadFile(String file)
read File
StringBuffer buffer = new StringBuffer();
try {
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));
    while (br.ready()) {
        buffer.append(br.readLine()).append("\n");
    br.close();
} catch (FileNotFoundException e) {
...
StringreadFile(String file)
Get a String representation of a text file
FileInputStream stream = new FileInputStream(file);
try {
    return readFile(stream);
} finally {
    stream.close();
StringreadFile(String file)
read File
FileReader rd = null;
try {
    rd = new FileReader(file);
} catch (FileNotFoundException e) {
    e.printStackTrace();
BufferedReader br = new BufferedReader(rd);
String text = new String();
...
StringreadFile(String file)
read File
StringBuilder sb = new StringBuilder();
LineNumberReader lnr = new LineNumberReader(new InputStreamReader(new FileInputStream(file)));
while (true) {
    String line = lnr.readLine();
    if (line == null)
        break;
    line = line.trim();
    sb.append(line);
...