Java Utililty Methods InputStreamReader Read

List of utility methods to do InputStreamReader Read

Description

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

Method

StringBufferreadFile(String fileName)
read File
InputStream fis = openFile(fileName);
BufferedReader buffer = null;
StringBuffer sb = new StringBuffer();
String s = null;
try {
    buffer = new BufferedReader(new InputStreamReader(fis));
    while ((s = buffer.readLine()) != null) {
        sb.append(s);
...
Stringreadfile(String filename)
Read the contents of a file.
InputStream input = null;
if (filename == null)
    input = System.in;
else
    input = new FileInputStream(filename);
InputStreamReader rdr = new InputStreamReader(input, "UTF-8");
int c = 0;
StringBuilder buf = new StringBuilder();
...
StringreadFile(String filename, boolean addEOL)
read File
StringBuffer buf = new StringBuffer();
BufferedReader bufReader = null;
try {
    FileInputStream fis = new FileInputStream(filename);
    bufReader = new BufferedReader(new InputStreamReader(fis));
    String line = "";
    while ((line = bufReader.readLine()) != null) {
        buf.append(line);
...
StringreadFile(String fileName, Class clazz)
read File
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
try {
    br = new BufferedReader(new InputStreamReader(clazz.getResourceAsStream(fileName)));
    String line;
    while ((line = br.readLine()) != null) {
        sb.append(line + "\n");
} catch (IOException e) {
    e.printStackTrace();
} finally {
    try {
        if (br != null) {
            br.close();
    } catch (IOException e) {
        e.printStackTrace();
return sb.toString();
StringreadFile(String fileName, String characterEncoding)
Reads a file and sends it to a buffer for parsing.
FileInputStream fis;
InputStreamReader isr;
StringBuffer sb = new StringBuffer(75000);
char[] buf = new char[4096];
int numRead;
fis = new FileInputStream(fileName);
isr = new InputStreamReader(fis, characterEncoding);
do {
...
StringreadFile(String fileName, String characterEncoding)
read File
FileInputStream fis;
InputStreamReader isr;
StringBuilder sb = new StringBuilder(75000);
char[] buf = new char[4096];
int numRead;
fis = new FileInputStream(fileName);
isr = new InputStreamReader(fis, characterEncoding);
do {
...
StringreadFile(String fileName, String characterEncoding)
read File
FileInputStream fis;
InputStreamReader isr;
StringBuilder sb = new StringBuilder(75000);
char[] buf = new char[4096];
int numRead;
fis = new FileInputStream(fileName);
isr = new InputStreamReader(fis, characterEncoding);
do {
...
StringreadFile(String fileName, String charSet)
read File
InputStreamReader in = null;
try {
    in = new InputStreamReader(new FileInputStream(fileName), charSet);
    StringBuffer content = new StringBuffer();
    int line = -1;
    while ((line = in.read()) != -1) {
        content.append((char) line);
    return content.toString();
} catch (Exception ex) {
    ex.printStackTrace();
} finally {
    if (in != null) {
        try {
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
return null;
StringBufferreadFile(String fileName, String coloredLineIndicator, boolean useSections, boolean isXML)
read File
FileInputStream fis = null;
StringBuffer outputBuffer = new StringBuffer();
try {
    fis = new FileInputStream(fileName);
    InputStreamReader inputStreamReader = new InputStreamReader(fis);
    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
    String bufferString = "";
    if (useSections) {
...
StringreadFile(String filename1)
read File
File f = new File(filename1);
if (!f.exists())
    return null;
FileInputStream fis = null;
InputStreamReader fsr = null;
StringBuilder out = new StringBuilder();
int len;
char[] buffer = new char[1024];
...