Android Utililty Methods Reader Read

List of utility methods to do Reader Read

Description

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

Method

voidcopy(Reader input, OutputStream output)
Serialize chars from a Reader to bytes on an OutputStream, and flush the OutputStream.
OutputStreamWriter out = new OutputStreamWriter(output);
copy(input, out);
out.flush();
intcopy(Reader input, Writer output)
Copy chars from a Reader to a Writer.
char[] buffer = new char[DEFAULT_BUFFER_SIZE];
int count = 0;
int n = 0;
while (-1 != (n = input.read(buffer))) {
    output.write(buffer, 0, n);
    count += n;
return count;
...
StringreadContents(Reader in)
Returns the full contents of the Reader as a String.
Writer out = null;
try {
    out = new StringWriter();
    copyContents(in, out);
    return out.toString();
} finally {
    try {
        out.close();
...
StringreadFile(String filename)
read File
File in = new File(filename);
try {
    Reader fr = new InputStreamReader(new FileInputStream(in),
            "UTF-8");
    char[] cbuf = new char[(int) in.length()];
    try {
        fr.read(cbuf);
        String ret = String.valueOf(cbuf);
...
ReaderreadFileReader(String filePath)
read File Reader
File file = new File(filePath);
FileInputStream fileInputStream = null;
try {
    fileInputStream = new FileInputStream(file);
} catch (FileNotFoundException e) {
    throw e;
return new InputStreamReader(fileInputStream);
...
StringreadTextFile(String fileName)
read text from a specified text file store in temporary path
try {
    File file = new File(FileUtil.tmpdir + fileName + ".txt");
    FileReader reader = new FileReader(file);
    BufferedReader in = new BufferedReader(reader);
    String line;
    StringBuffer sb = new StringBuffer();
    while ((line = in.readLine()) != null) {
        sb.append(line);
...
String[]slurpLines(final Reader reader)
Read all lines from a file.
checkSourceNotNull(reader);
final BufferedReader bufferedReader = new BufferedReader(reader);
final List<String> lines = new ArrayList<String>();
String line;
while ((line = bufferedReader.readLine()) != null) {
    lines.add(line);
closeCleanly(bufferedReader, "reader for slurpLines");
...
String[]slurpValidLines(final Reader reader)
Read lines from a reader but skip blank lines and those beginning with a '#'
final List<String> validLines = new ArrayList<String>();
for (String line : slurpLines(reader)) {
    line = line.trim();
    if (line.length() == 0 || line.charAt(0) == '#') {
        continue;
    validLines.add(line);
return validLines.toArray(new String[validLines.size()]);
ListtoList(Reader reader)
to List
List list = new ArrayList();
try {
    BufferedReader br = new BufferedReader(reader);
    StringBuffer sb = new StringBuffer();
    String line = null;
    while ((line = br.readLine()) != null) {
        list.add(line);
    br.close();
} catch (IOException ioe) {
return list;
StringnextString(Reader r)
Parse white space delimited String from Reader.
StringWriter sw = new StringWriter();
try {
    char buffer;
    int i;
    while ((i = r.read()) > -1) {
        buffer = (char) i;
        if (!Character.isWhitespace(buffer)) {
            sw.write(buffer);
...