Android BufferedReader Read readStringFromBufferedReader(BufferedReader br)

Here you can find the source of readStringFromBufferedReader(BufferedReader br)

Description

Reads all content from the given Reader and returns it as a single String

License

Open Source License

Parameter

Parameter Description
br the file

Exception

Parameter Description
IOException an exception

Return

the file content as String

Declaration

private static String readStringFromBufferedReader(BufferedReader br)
        throws IOException 

Method Source Code

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.net.URL;
import java.util.UUID;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import net.sf.json.JSON;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;

public class Main{
    /**/*from  www . jav  a  2s  .  c o  m*/
     * Reads all content from the given {@link Reader} and returns it as a single {@link String}
     *
     * @param br the file
     * @return the file content as String
     * @throws IOException
     */
    private static String readStringFromBufferedReader(BufferedReader br)
            throws IOException {
        StringBuffer sbr = new StringBuffer();
        for (String ln = br.readLine(); ln != null; ln = br.readLine())
            sbr.append(ln + "\n");
        br.close();
        return sbr.toString();
    }
}

Related

  1. getFileContent(File f)
  2. readFileAsString(File file)
  3. readFileFolder(String filePath)
  4. readStream(Reader r)
  5. toList(String fileName)