Java Utililty Methods InputStreamReader Create

List of utility methods to do InputStreamReader Create

Description

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

Method

StringBufferreadTextFile(Reader reader)
reads a Text file from its resource.
StringBuffer sb = new StringBuffer(10000);
int c = 0;
while ((c = reader.read()) > -1) {
    sb.append((char) c);
reader.close();
return sb;
ArrayListreadTextFile(String fileName)
read Text File
ArrayList<String> strs = new ArrayList<String>();
try {
    BufferedReader bin = new BufferedReader(new InputStreamReader(new FileInputStream(new File(fileName))));
    String line;
    while ((line = bin.readLine()) != null) {
        line = line.trim();
        if (line.length() != 0)
            strs.add(line);
...
StringreadTextFile(String filename, int maxNumLines, boolean startAtBeginning)
Read in the last few lines of a (newline delimited) textfile, or null if the file doesn't exist.
File f = new File(filename);
if (!f.exists())
    return null;
FileInputStream fis = null;
BufferedReader in = null;
try {
    fis = new FileInputStream(f);
    in = new BufferedReader(new InputStreamReader(fis, "UTF-8"));
...
ArrayListreadTextFile(String filePath, String charset)
read Text File
if (!checkFile(filePath, false)) {
    return null;
ArrayList<String> data = new ArrayList<String>();
FileInputStream in = null;
BufferedReader r = null;
try {
    in = new FileInputStream(filePath);
...
StringreadTextFile(String fullPathFilename)
read Text File
return readTextFile(new FileInputStream(fullPathFilename));
StringreadTextFile(String realPath)
read Text File
File file = new File(realPath);
if (!file.exists()) {
    System.out.println("File not exist!");
    return null;
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(realPath), "UTF-8"));
String temp = "";
String txt = "";
...
String[]readTextFileAsStringArray(final File file, final String charSet)
Read a text file into string array
final BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), charSet));
final List<String> readString = new ArrayList<String>(256);
try {
    while (true) {
        final String line = reader.readLine();
        if (line == null) {
            break;
        readString.add(line);
} finally {
    silentlyClose(reader);
return readString.toArray(new String[readString.size()]);