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 path)
Reads a file and returns the content as a big String.
StringBuilder buffer = new StringBuilder();
try {
    BufferedReader reader = new BufferedReader(new FileReader(new File(path)));
    String line;
    while ((line = reader.readLine()) != null)
        buffer.append(line).append('\n');
} catch (FileNotFoundException ex) {
    System.err.println("File " + path + " was not found...");
...
ListreadFile(String pathname)
Reads the file at the specified pathname and returns it as a List of Strings, one per line of the file.
List<String> lines = new ArrayList<>();
BufferedReader reader = new BufferedReader(new FileReader(pathname));
while (reader.ready()) {
    lines.add(reader.readLine());
reader.close();
return lines;
StringreadFile(String sFileName_)
Reads a File and returns the content in a String.
StringBuffer sFileContent = new StringBuffer(100000);
try {
    FileReader frIni = new FileReader(sFileName_);
    if (frIni != null) {
        BufferedReader brIni = new BufferedReader(frIni);
        if (brIni != null) {
            while (brIni.ready()) {
                String sLine = brIni.readLine();
...
StringreadFile(String uri)
Read file.
File file = new File(uri);
FileReader fr = new FileReader(file.getAbsoluteFile());
BufferedReader br = new BufferedReader(fr);
String value = br.readLine();
br.close();
return value;
StringreadFile(String xmlFile)
read File
StringBuffer fileContent = new StringBuffer();
try {
    FileReader reader = new FileReader(new File(xmlFile));
    BufferedReader buffer = new BufferedReader(reader);
    String line = "";
    int i = 0;
    while ((line = buffer.readLine()) != null) {
        if (i != 0)
...
HashMapreadFileAsHash(File file)
read File As Hash
StringBuffer stringBuffer = new StringBuffer();
HashMap<String, String> pairs = new HashMap<String, String>();
try {
    BufferedReader in = new BufferedReader(new FileReader(file));
    try {
        int size = 0;
        char[] buff = new char[512];
        while ((size = in.read(buff)) >= 0) {
...
ListreadFileAsLines(File fileLocation)
read File As Lines
List<String> lines = new ArrayList<String>();
FileReader fr = null;
BufferedReader br = null;
if (fileLocation != null) {
    try {
        fr = new FileReader(fileLocation);
        br = new BufferedReader(fr);
        String line = null;
...
ListreadFileAsLines(String aFile)
read File As Lines
BufferedReader input = new BufferedReader(new FileReader(aFile));
List<String> lines = new Vector<String>();
try {
    String line = null; 
    while ((line = input.readLine()) != null) {
        lines.add(line);
} finally {
...
ListreadFileAsList(final String filename)
read File As List
final File f = new File(filename);
if (f.exists()) {
    return readFileAsList(f);
return null;
ListreadFileAsList(String filename, String splitter)
read File As List
List<String> list = new ArrayList<String>();
File file = new File(filename);
FileReader freader = new FileReader(file);
StringBuilder builder = new StringBuilder();
try (BufferedReader breader = new BufferedReader(freader)) {
    String line = breader.readLine();
    while (null != line) {
        builder.append(line);
...