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

StringBufferreadTextFile(String fileName, boolean newline)
read Text File
File file = new File(fileName);
if (!file.exists()) {
    throw new FileNotFoundException();
StringBuffer buf = new StringBuffer();
BufferedReader in = null;
try {
    in = new BufferedReader(new FileReader(file));
...
StringreadTextFile(String fileName, String enc)
Reads a character file into a string.
String lineSep = System.getProperty("line.separator");
StringBuffer retVal = new StringBuffer();
try {
    BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), enc));
    String line = null;
    while ((line = in.readLine()) != null) {
        retVal.append(line);
        retVal.append(lineSep);
...
String[]readTextFile(String filePath)
read Text File
BufferedReader br = new BufferedReader(new FileReader(filePath));
ArrayList<String> fileContents = new ArrayList<String>();
String line = br.readLine();
while (line != null) {
    fileContents.add(line);
    line = br.readLine();
br.close();
...
StringreadTextFile(String filePath)
read Text File
String str = null;
BufferedReader br = null;
try {
    br = new BufferedReader(new FileReader(filePath));
    StringBuilder sb = new StringBuilder();
    String line = br.readLine();
    while (line != null) {
        sb.append(line);
...
StringreadTextFile(String filePath)
Read a text file and return its content as string.
File file = new File(filePath);
StringBuffer contents = new StringBuffer();
BufferedReader reader = null;
try {
    reader = new BufferedReader(new FileReader(file));
    String text = null;
    while ((text = reader.readLine()) != null) {
        contents.append(text).append(System.getProperty("line.separator"));
...
StringreadTextFile(String fullPathFilename)
Method readTextFile.
StringBuilder sb = new StringBuilder(1024);
BufferedReader reader = new BufferedReader(new FileReader(fullPathFilename));
char[] chars = new char[1024];
int numRead = 0;
while ((numRead = reader.read(chars)) > -1) {
    sb.append(String.valueOf(chars, 0, numRead));
reader.close();
...
StringreadTextFile(String path)
Reads the specified text file and returns their contents in a String
File file = new File(path);
if (!file.exists()) {
    file.createNewFile();
    return "";
BufferedReader reader = new BufferedReader(new FileReader(file));
StringBuilder content = new StringBuilder();
String line = "";
...
StringreadTextFile(String path)
read Text File
String newLine = System.getProperty("line.separator");
StringBuffer sb = new StringBuffer();
BufferedReader input = new BufferedReader(new FileReader(path));
String line;
while (null != (line = input.readLine())) {
    if (sb.length() > 0)
        sb.append(newLine);
    sb.append(line);
...
StringreadTextFile(String text_file_name)
read Text File
BufferedReader br = new BufferedReader(new FileReader(new File(text_file_name)));
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = br.readLine()) != null)
    buffer.append(line + "\n");
br.close();
return buffer.toString();
StringreadTextFile(String text_file_name)
read Text File
BufferedReader br = new BufferedReader(new FileReader(new File(text_file_name)));
StringBuffer buffer = new StringBuffer();
String line = "";
while ((line = br.readLine()) != null)
    buffer.append(line + "\n");
br.close();
return buffer.toString();