Java Text File Read getFileContentAsString(String path)

Here you can find the source of getFileContentAsString(String path)

Description

get File Content As String

License

Apache License

Declaration

public static String getFileContentAsString(String path) throws Exception 

Method Source Code

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

import java.io.BufferedReader;

import java.io.FileInputStream;

import java.io.InputStreamReader;

public class Main {
    public static String getFileContentAsString(String path) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(path), "UTF-8"));
        String data = new String();
        try {//from   w ww  .j ava 2  s .  c o m
            String line;
            while ((line = br.readLine()) != null) {
                data = data.concat(line);
            }
        } finally {
            br.close();
        }
        return data;
    }
}

Related

  1. getChars(File file)
  2. getChars(Reader r)
  3. getFileContentAsString(File cpfile)
  4. getFileContentAsString(final String filePath)
  5. getFileContentAsString(InputStream inputStream)
  6. getFileContents(Reader reader)
  7. getFileContents(String filePath)
  8. getFileContents(String filePath)
  9. getFileContents(String filePath)