Java Utililty Methods FileReader Create

List of utility methods to do FileReader Create

Description

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

Method

StringreadTextFile(File file)
read Text File
StringBuilder fileData = new StringBuilder(1000);
BufferedReader reader = new BufferedReader(new FileReader(file));
char[] buf = new char[1024];
int numRead = 0;
while ((numRead = reader.read(buf)) != -1) {
    String readData = String.valueOf(buf, 0, numRead);
    fileData.append(readData);
    buf = new char[1024];
...
StringBufferreadTextFile(File file, boolean newline)
read Text File
if (!file.exists()) {
    throw new FileNotFoundException();
StringBuffer buf = new StringBuffer();
BufferedReader in = null;
try {
    in = new BufferedReader(new FileReader(file));
    String str;
...
String[][]readTextFile(File file, int header)
Generic function to read a text file into a double[][] with an arbitrary number of columns.
String[][] output = null;
BufferedReader reader = null;
try {
    reader = new BufferedReader(new FileReader(file));
    for (int i = 1; i <= header; i++) {
        reader.readLine();
    String line = reader.readLine();
...
StringreadTextfile(final String filename)
Reads a text file into a string.
return readTextfile(new File(filename));
String[]readTextFile(InputStream in)
Reads the text from the given input stream in the default encoding.
return readTextFile(in, null);
String[]readTextFile(InputStream in)
Reads the text from the given input stream in the default encoding.
return readTextFile(in, null);
StringBufferreadTextFile(String completePath)
Read a textfile into a StringBuffer.
StringBuffer buf = new StringBuffer();
File file = new File(completePath);
try {
    FileReader fr = new FileReader(file);
    char buffer[] = new char[1024];
    int read = 1;
    while (read > 0) {
        read = fr.read(buffer);
...
StringreadTextFile(String file)
read Text File
StringBuffer buffer = new StringBuffer(1024);
BufferedReader reader = new BufferedReader(new FileReader(file));
char[] chars = new char[1024];
while ((reader.read(chars)) > -1) {
    buffer.append(String.valueOf(chars));
reader.close();
return buffer.toString();
...
StringreadTextFile(String file)
Read the file into a String.
File rFile = new File(file);
StringBuffer sb = new StringBuffer(1024);
BufferedReader reader = new BufferedReader(new FileReader(rFile.getPath()));
char[] chars = new char[1];
try {
    while ((reader.read(chars)) > -1) {
        sb.append(String.valueOf(chars));
        chars = new char[1];
...
StringreadTextFile(String file)
read Text File
String everything;
try (BufferedReader br = new BufferedReader(new FileReader(file))) {
    StringBuilder sb = new StringBuilder();
    String line = br.readLine();
    while (line != null) {
        sb.append(line);
        sb.append(System.lineSeparator());
        line = br.readLine();
...