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

StringreadTextFile(File file)
read Text File
FileInputStream fis = null;
InputStreamReader isr = null;
BufferedReader br = null;
try {
    StringWriter sw = new StringWriter();
    fis = new FileInputStream(file);
    isr = new InputStreamReader(fis, "UTF-8");
    br = new BufferedReader(isr);
...
StringreadTextFile(File file)
read Text File
String text = null;
InputStream is = null;
try {
    is = new FileInputStream(file);
    text = readTextInputStream(is);
} finally {
    if (is != null) {
        is.close();
...
StringreadTextFile(File file, String charsetName)
read Text File
StringBuffer sb = new StringBuffer(DEFAULT_BUFFER_SIZE);
FileInputStream fis = new FileInputStream(file);
BufferedReader reader = new BufferedReader(
        charsetName == null ? new InputStreamReader(fis) : new InputStreamReader(fis, charsetName));
char[] chars = new char[DEFAULT_BUFFER_SIZE];
int numRead = 0;
while ((numRead = reader.read(chars)) > -1) {
    sb.append(String.valueOf(chars, 0, numRead));
...
StringreadTextFile(File fromFile)
Read the String content from File.
StringBuffer buf = new StringBuffer();
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fromFile)));
String inputLine;
while ((inputLine = in.readLine()) != null) {
    buf.append(inputLine);
    buf.append('\n');
in.close();
...
StringreadTextFile(File inputFile)
Reads a text file.
FileInputStream in = null;
try {
    in = new FileInputStream(inputFile);
    return readTextFile(in);
} finally {
    if (in != null) {
        try {
            in.close();
...
StringreadTextFile(File path)
Read a text file from a given path
try {
    FileInputStream is = new FileInputStream(path);
    BufferedReader bin = new BufferedReader(new InputStreamReader(is, "UTF-8"));
    StringBuilder sb = new StringBuilder();
    String line = null;
    while ((line = bin.readLine()) != null) {
        sb.append(line);
        sb.append(System.getProperty("line.separator"));
...
StringreadTextFile(final File f)
Read text file into a String.
final StringBuilder sb = new StringBuilder((int) f.length());
BufferedReader br = null;
try {
    br = new BufferedReader(new InputStreamReader(new FileInputStream(f), FILE_ENCODING_8859_1));
    String inputLine;
    while ((inputLine = br.readLine()) != null) {
        sb.append(inputLine.trim());
        sb.append('\n');
...
StringreadTextFile(final File file)
read Text File
try {
    return readCloseTextStream(new FileInputStream(file));
} catch (FileNotFoundException e) {
    System.err.println("readTextFile: File " + file + " not found.");
return "";
StringReadTextFile(InputStream is)
Read Text File
DataInputStream dis = new DataInputStream(is);
BufferedReader br = new BufferedReader(new InputStreamReader(dis), 16 * 1024);
StringBuilder str = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
    str.append(line);
    str.append("\n");
dis.close();
return str.toString();
StringreadTextFile(java.io.File file)
Read text file to a string.
return readTextFile(file, null);