Java File to String readFileAsString(String fpath)

Here you can find the source of readFileAsString(String fpath)

Description

read File As String

License

Open Source License

Declaration

public static String readFileAsString(String fpath) throws IOException 

Method Source Code


//package com.java2s;
import java.io.BufferedReader;

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

public class Main {
    public static String readFileAsString(String fpath) throws IOException {

        final BufferedReader brdr = new BufferedReader(new FileReader(fpath));
        final StringBuilder sr = new StringBuilder(fpath.length());
        String s = null;/*from w w  w . j a  v  a 2  s  .c o m*/
        try {
            while ((s = brdr.readLine()) != null) {
                sr.append(s).append('\n');
            }
        } finally {
            brdr.close();
        }
        return sr.toString();
    }
}

Related

  1. readFileAsString(String filePath)
  2. readFileAsString(String filePath)
  3. readFileAsString(String filePathname)
  4. readFileAsString(String fname)
  5. readFileAsString(String fname)
  6. readFileAsString(String path)
  7. readFileAsString(String path)
  8. readFileAsString(String path)
  9. readFileAsString(String path)