Java File Content Read getFileContent(String fileName)

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

Description

get File Content

License

Open Source License

Declaration

public static String getFileContent(String fileName) throws Exception 

Method Source Code


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

import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
import java.io.DataInputStream;

public class Main {
    public static String getFileContent(String fileName) throws Exception {
        File file = new File(fileName);
        FileInputStream fis = new FileInputStream(file);
        BufferedInputStream bis = new BufferedInputStream(fis);
        DataInputStream dis = new DataInputStream(bis);
        StringBuffer content = new StringBuffer();
        while (dis.available() != 0) {
            content.append(dis.readLine());
        }/*  ww w  . ja  v  a  2  s.  c o  m*/
        fis.close();
        bis.close();
        dis.close();
        return content.toString();
    }
}

Related

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