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

Stringload(String filename)
load
try {
    FileReader f = new FileReader(filename);
    char[] buf = new char[10 * 1024];
    StringBuffer s = new StringBuffer();
    int hasread = f.read(buf);
    while (hasread != -1) {
        s.append(buf, 0, hasread);
        hasread = f.read(buf);
...
Tload(String fileName, Class klass)
load
File file = new File(fileName);
Gson gson = new Gson();
try (FileReader rdr = new FileReader(file)) {
    return gson.fromJson(rdr, klass);
HashtableloadIndex(File root_)
Loads an index (Hashtable) from a file.
return loadIndex(root_, "index");
JsonObjectloadJSON(File file)
load JSON
return loadJSON(new FileReader(file));
ArrayListloadKeggInteractions(String species, String location)
load Kegg Interactions
ArrayList<String> kegg = new ArrayList<String>();
String fileName = location + species + "_kegg_edges.txt";
try {
    FileReader fr = new FileReader(fileName);
    LineNumberReader lnr = new LineNumberReader(fr);
    String s = null;
    while ((s = lnr.readLine()) != null) {
        s = s.trim();
...
StringreadFile(File f)
read File
final char[] buffer = new char[8192];
int bufferLength = 0;
StringBuffer textBuffer = new StringBuffer();
Reader reader = new FileReader(f);
while (bufferLength != -1) {
    bufferLength = reader.read(buffer);
    if (bufferLength > 0) {
        textBuffer.append(new String(buffer, 0, bufferLength));
...
StringreadFile(File f)
read File
long n = f.length();
char[] cbuf = new char[(int) n];
FileReader fr = new FileReader(f);
fr.read(cbuf);
fr.close();
return (new String(cbuf));
StringreadFile(File file)
read File
Reader in = new FileReader(file);
StringBuilder buffer = new StringBuilder();
int i;
while ((i = in.read()) != -1)
    buffer.append((char) i);
in.close();
return buffer.toString();
StringreadFile(File file)
Deserializes the given file and returns its content as a string
Reader reader;
try {
    reader = new FileReader(file.getAbsolutePath());
} catch (FileNotFoundException e) {
    throw new Exception("Couldn't create reader", e);
String text = "";
try {
...
StringreadFile(File file)
read File
Reader reader = new FileReader(file);
try {
    StringBuilder sb = new StringBuilder();
    char[] buffer = new char[512];
    int n;
    while ((n = reader.read(buffer)) != -1)
        sb.append(buffer, 0, n);
    return sb.toString();
...