Java File Content Read getFileContent(String fName)

Here you can find the source of getFileContent(String fName)

Description

get File Content

License

Open Source License

Declaration

public static String getFileContent(String fName) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;

import java.io.InputStreamReader;

public class Main {

    public static String getFileContent(String fName) {
        File f = new File(fName);
        String ret = "";
        if (!f.exists()) {
            return ret;
        }//from   w ww  .ja v  a  2  s  .  com

        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(f)));
            String l;
            while ((l = br.readLine()) != null) {
                ret += l;
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return ret;
    }
}

Related

  1. getFileContent(String fileName)
  2. getFileContent(String fileName)
  3. getFileContent(String filepath)
  4. getFileContent(String filePath)
  5. getFileContent(String filePath)
  6. getFileContent(String path)
  7. getFileContent(String path)
  8. getFileContent(String path)
  9. getFileContent(String path)