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

ReadergetReader(final File file)
Method getReader
final FileInputStream fileinputstream = new FileInputStream(file);
final byte bytes[] = readUpTo(fileinputstream, 100);
fileinputstream.close();
final String s = normalizeEncoding(getEncoding(bytes));
return new InputStreamReader(new FileInputStream(file), s);
ReadergetReader(final InputStream is)
get Reader
final Reader result = new InputStreamReader(is);
return result;
ReadergetReader(String name, String extension)
get Reader
File f = new File(name);
if (f.exists())
    return new FileReader(f);
f = new File(name + extension);
if (f.exists())
    return new FileReader(f);
f = new File(name + ".gz");
if (!f.exists())
...
InputStreamReadergetReaderForFile(IFile file)
get Reader For File
InputStream contents = file.getContents();
InputStreamReader r = new InputStreamReader(contents, file.getCharset());
return r;
StringreadTextFile(File f)
read Text File
StringBuffer buf = new StringBuffer();
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
String inputLine;
while ((inputLine = in.readLine()) != null) {
    buf.append(inputLine);
    buf.append('\n');
in.close();
...
StringreadTextFile(File f)
read Text File
StringBuffer buf = new StringBuffer();
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
String inputLine;
while ((inputLine = in.readLine()) != null) {
    buf.append(inputLine);
    buf.append('\n');
in.close();
...
StringreadTextFile(File f)
read Text File
StringBuffer buf = new StringBuffer();
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
String inputLine;
while ((inputLine = in.readLine()) != null) {
    buf.append(inputLine);
    buf.append('\n');
in.close();
...
StringreadTextFile(File f)
read Text File
StringBuffer buf = new StringBuffer();
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
String inputLine;
while ((inputLine = in.readLine()) != null) {
    buf.append(inputLine);
    buf.append('\n');
in.close();
...
StringreadTextFile(File f)
read Text File
Reader br = new BufferedReader(new InputStreamReader(new FileInputStream(f), "UTF-8"));
return readText(br);
StringreadTextFile(File f, int maxNumLines)
Read in the last few lines of a (newline delimited) textfile, or null if the file doesn't exist.
if (!f.exists())
    return null;
FileInputStream fis = null;
BufferedReader in = null;
try {
    fis = new FileInputStream(f);
    in = new BufferedReader(new InputStreamReader(fis));
    List<String> lines = new ArrayList<String>(maxNumLines);
...