Java Utililty Methods BufferedReader Read

List of utility methods to do BufferedReader Read

Description

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

Method

StringreadFile(String file)
read File
StringBuilder stringBuilder = new StringBuilder();
BufferedReader reader = new BufferedReader(new FileReader(file));
try {
    String line = null;
    String ls = System.getProperty("line.separator");
    while ((line = reader.readLine()) != null) {
        stringBuilder.append(line);
        stringBuilder.append(ls);
...
voidReadFile(String file)
Read File
try {
    BufferedReader in = new BufferedReader(new FileReader(file));
    String str;
    while ((str = in.readLine()) != null) {
        System.out.println(str);
    in.close();
} catch (IOException ex) {
...
StringreadFile(String file)
Redid this file to remove sizing requirements and to make it faster Speeded it up 10 fold.
try {
    FileReader reader = new FileReader(file);
    BufferedReader read = new BufferedReader(reader);
    StringBuffer b = new StringBuffer();
    String s = null;
    int count = 0;
    while ((s = read.readLine()) != null) {
        count++;
...
StringreadFile(String file)
read File
if (!(new File(file).exists())) {
    throw new FileNotFoundException("Could not find " + file);
BufferedReader reader = new BufferedReader(new FileReader(file));
String content = "";
String line = "";
while ((line = reader.readLine()) != null) {
    content += line + "\r\n";
...
StringreadFile(String file)
read File
BufferedReader br = null;
StringBuilder text = new StringBuilder();
try {
    br = new BufferedReader(new FileReader(new File(file)));
    String line;
    while ((line = br.readLine()) != null) {
        text.append(line);
} catch (Exception e) {
} finally {
    if (br != null) {
        try {
            br.close();
        } catch (IOException e) {
            e.printStackTrace();
        br = null;
return text.toString();
StringreadFile(String file)
Read file.
String result = "";
System.out.println("Reading file " + file + "...");
try {
    FileReader reader = new FileReader(file);
    BufferedReader bReader = new BufferedReader(reader);
    String line = "";
    while (line != null) {
        line = bReader.readLine();
...
StringreadFile(String file)
read File
StringBuilder stringBuilder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
    String line;
    while ((line = reader.readLine()) != null) {
        stringBuilder.append(line);
    return stringBuilder.toString();
StringreadFile(String file, Boolean deleteOnExit)
read File
return fileReader.apply(file, deleteOnExit);
ListreadFile(String fileDir)
read File
File file = new File(fileDir);
List<String> fileList = new ArrayList<String>();
if (!file.exists()) {
    System.err.println("File Not exist!");
FileReader fileReader = new FileReader(file);
BufferedReader br = new BufferedReader(fileReader);
String strLine = "";
...
StringreadFile(String filename)
read File
StringBuilder builder = new StringBuilder();
BufferedReader reader = new BufferedReader(new FileReader(filename));
String line;
while ((line = reader.readLine()) != null) {
    builder.append(line);
    builder.append(System.getProperty("line.separator"));
reader.close();
...