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

StringreadFile(File file)
read File
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
try {
    StringBuilder ret = new StringBuilder();
    String line;
    while ((line = reader.readLine()) != null) {
        ret.append(line);
        ret.append("\n");
    return ret.toString();
} finally {
    reader.close();
ArrayListreadFile(File file)
read File
return readFile(file, "UTF8");
StringreadFile(File file)
read File
Reader in = new FileReader(file);
StringWriter out = new StringWriter();
copy(in, out);
return out.toString();
ListreadFile(File file)
read File
List<String> lines = new ArrayList<String>();
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file)));
String line;
while ((line = reader.readLine()) != null) {
    lines.add(line);
reader.close();
return lines;
...
StringreadFile(File file)
read File
StringBuilder result = new StringBuilder();
BufferedReader in = null;
try {
    in = new BufferedReader(new InputStreamReader(new FileInputStream(file), ENCODING));
    String line;
    while ((line = in.readLine()) != null) {
        result.append(line);
        result.append("\n");
...
ListreadFile(File file)
Reads the content of the provided file.
InputStream is = new FileInputStream(file);
if (file.getName().toLowerCase().endsWith(".gz"))
    is = new GZIPInputStream(is);
List<String> lines = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(is))) {
    String line = reader.readLine();
    while (line != null) {
        lines.add(line);
...
StringreadFile(File file)
read File
StringBuilder buffy = new StringBuilder();
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF8"));
String str;
while ((str = in.readLine()) != null) {
    buffy.append(str).append("\n");
in.close();
return buffy.toString();
...
StringReadFile(File file)
Read File
StringBuilder result = new StringBuilder();
BufferedReader reader = null;
try {
    reader = new BufferedReader(new FileReader(file));
    char[] buf = new char[1024];
    int r = 0;
    while ((r = reader.read(buf)) != -1) {
        result.append(buf, 0, r);
...
ListreadFile(File file)
read File
List<String> lines = new ArrayList<String>();
try {
    FileInputStream fstream = new FileInputStream(file);
    DataInputStream in = new DataInputStream(fstream);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String line;
    while ((line = br.readLine()) != null) {
        lines.add(line);
...
StringreadFile(File file)
read File
return readStream(new FileInputStream(file));