Java Utililty Methods BufferedReader Read All

List of utility methods to do BufferedReader Read All

Description

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

Method

StringreadAll(InputStream stream)
read All
BufferedReader reader = null;
try {
    reader = new BufferedReader(new InputStreamReader(stream));
    StringBuilder b = new StringBuilder();
    String line = null;
    while ((line = reader.readLine()) != null) {
        b.append(line);
    return b.toString();
} finally {
    if (reader != null)
        reader.close();
StringreadAll(Reader reader)
read All
StringBuilder buf = new StringBuilder();
int in;
while ((in = reader.read()) != -1) {
    char ch = (char) in;
    buf.append(ch);
return buf.toString();
StringreadAll(Reader reader)
read All
BufferedReader bufferedReader = new BufferedReader(reader);
StringBuilder builder = new StringBuilder();
String line;
while ((line = bufferedReader.readLine()) != null) {
    builder.append(line).append("\n");
bufferedReader.close();
return builder.toString();
...
StringreadAll(Reader reader)
read All
StringBuffer buffer = new StringBuffer();
BufferedReader in = new BufferedReader(reader);
int ch;
while ((ch = in.read()) > -1) {
    buffer.append((char) ch);
in.close();
return buffer.toString();
...
StringreadAll(Reader reader)
Suck all the data from a Reader into a String .
StringBuilder result = new StringBuilder();
BufferedReader buffered = new BufferedReader(reader);
char[] chunk = new char[4096];
int howMany;
try {
    while (-1 != (howMany = buffered.read(chunk))) {
        result.append(chunk, 0, howMany);
} finally {
    reader.close();
return result.toString();
SetreadAll(String fileName)
read All
BufferedReader reader = new BufferedReader(new FileReader(fileName));
Set<String> s = new HashSet<String>();
String line;
while ((line = reader.readLine()) != null) {
    if (!"".equals(line)) {
        s.add(line);
return s;
StringreadAll(String fileName)
read All
StringBuilder sb = new StringBuilder();
Reader fr = new InputStreamReader(ClassLoader.class.getResourceAsStream(fileName), "UTF-8");
BufferedReader br = new BufferedReader(fr);
String s;
while ((s = br.readLine()) != null) {
    sb.append(s);
fr.close();
...
StringreadAll(String filePath)
read All
try {
    FileReader fr = new FileReader(filePath);
    BufferedReader br = new BufferedReader(fr);
    String res = "";
    String buf;
    while ((buf = br.readLine()) != null) {
        res += buf;
    br.close();
    fr.close();
    return res;
} catch (IOException e) {
    e.printStackTrace();
return null;
StringreadAll(String filePathAndName)
read text file content, return string split by "\n"
return readAll(filePathAndName, DEFAULT_ENCODING);
ListreadAll(String ip)
read All
if (ip == null) {
    return null;
BufferedReader br = null;
List<String> result = new ArrayList<String>();
File file = null;
synchronized (monitor) {
    try {
...