Java Utililty Methods FileReader Read

List of utility methods to do FileReader Read

Description

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

Method

JsonReaderreadFile(final String fileName)
read File
try {
    return new JsonReader(new FileReader(filePath(fileName)));
} catch (FileNotFoundException e) {
    e.printStackTrace();
return null;
StringreadFile(Reader reader)
read File
return readerToString(reader);
StringreadFile(String file)
read File
StringBuilder sb = new StringBuilder();
Reader in = null;
try {
    in = new FileReader(file);
    char[] buffer = new char[8192];
    int length;
    while ((length = in.read(buffer)) != -1) {
        sb.append(buffer, 0, length);
...
ReaderreadFile(String file)
read File
try {
    return new FileReader(file);
} catch (FileNotFoundException e) {
    return null;
String[]readFile(String filename)
read File
return readFile(new File(filename));
StringreadFile(String filename)
read File
String content = null;
File file = new File(filename);
FileReader reader = null;
try {
    reader = new FileReader(file);
    char[] chars = new char[(int) file.length()];
    reader.read(chars);
    content = new String(chars);
...
StringreadFile(String filename)
read File
String return_str = "";
try {
    FileReader fr = new FileReader(filename);
    LineNumberReader lr = new LineNumberReader(fr, 512);
    while (true) {
        String str = lr.readLine();
        if (str == null)
            break;
...
StringreadFile(String fileName)
Reads file to a string.
Reader reader = new FileReader(fileName);
try {
    StringBuilder sb = new StringBuilder();
    char[] buffer = new char[1024];
    int k = 0;
    while ((k = reader.read(buffer)) != -1) {
        sb.append(buffer, 0, k);
    return sb.toString().replace("\r\n", "\n");
} finally {
    try {
        reader.close();
    } catch (IOException ioe) {
StringreadFile(String fileName)
read File
String content;
File file = new File(fileName);
FileReader reader = new FileReader(file);
char[] chars = new char[(int) file.length()];
reader.read(chars);
content = new String(chars);
reader.close();
return content;
...
StringreadFile(String fileName)
Reads the content of a given file.
Reader reader = new FileReader(fileName);
try {
    StringBuilder sb = new StringBuilder();
    char[] buffer = new char[1024];
    int k = 0;
    while ((k = reader.read(buffer)) != -1) {
        sb.append(buffer, 0, k);
    return sb.toString().replace("\r\n", "\n");
} finally {
    reader.close();