Java BufferedReader Read readFilePathToString(String filePath)

Here you can find the source of readFilePathToString(String filePath)

Description

read File Path To String

License

Open Source License

Declaration

public static String readFilePathToString(String filePath) throws IOException 

Method Source Code


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

import java.io.BufferedReader;

import java.io.FileReader;
import java.io.IOException;

public class Main {
    public static String readFilePathToString(String filePath) throws IOException {
        StringBuffer fileData = new StringBuffer(2048);
        BufferedReader reader = new BufferedReader(new FileReader(filePath));
        char[] buf = new char[1024];
        int numRead = 0;
        while ((numRead = reader.read(buf)) != -1) {
            String readData = String.valueOf(buf, 0, numRead);
            fileData.append(readData);/*from ww w  .ja  v a  2  s. co m*/
            buf = new char[1024];
        }
        reader.close();
        return fileData.toString();
    }
}

Related

  1. readFileAsText(String path)
  2. readFileByChar(String path)
  3. readFileContext(File fileToRead)
  4. readFileEncoding(String file)
  5. readFileGdeHash(File gdeFile, ArrayList name, ArrayList seq)
  6. readFileToHashMap(String filePath, String separator, boolean valueFirst)
  7. readFileToHashMap(String filePath, String separator, boolean valueFirst)
  8. readFileToList(String fileName, List list)
  9. readFileToList(String path, String split)