Java BufferedReader Read loadAFileToString2(File f)

Here you can find the source of loadAFileToString2(File f)

Description

load A File To String

License

Apache License

Declaration

public static String loadAFileToString2(File f) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    public static String loadAFileToString2(File f) {
        InputStream is = null;/* w  w w. j a v  a2 s.c  o  m*/
        String ret = "";
        if (f.exists()) {
            BufferedReader br = null;
            try {
                String line;
                is = new FileInputStream(f);
                InputStreamReader read = new InputStreamReader(is, "utf-8");
                br = new BufferedReader(read);
                while ((line = br.readLine()) != null) {
                    ret += line + "\r\n";
                }
            } catch (Exception e) {
                ret = "";
            } finally {
                if (is != null) {
                    try {
                        is.close();
                    } catch (Exception e) {
                    }
                }
            }
        }
        return ret;
    }
}

Related

  1. load(File pFile)
  2. load(final Multimap map, final Reader source)
  3. load(final String path, final String file)
  4. load(String filename)
  5. loadAddressList(String filename)
  6. loadAPIKey(InputStream in)
  7. loadAuthFile(String fileName)
  8. loadBase64Object(BufferedReader rdr, String type)
  9. loadBlackList(String blackListPath)