Java Text File Read loadAsString(String location)

Here you can find the source of loadAsString(String location)

Description

load As String

License

Open Source License

Declaration

public static String loadAsString(String location) 

Method Source Code


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

import java.io.BufferedReader;
import java.io.FileReader;

public class Main {
    public static String loadAsString(String location) {
        final StringBuilder result = new StringBuilder();
        try {//from  www  .ja  v  a  2 s  . c o m
            final BufferedReader reader = new BufferedReader(new FileReader(location));
            String buffer = "";
            while ((buffer = reader.readLine()) != null) {
                result.append(buffer).append("\n");
            }
            reader.close();
        } catch (final Exception e) {
            System.err.println(e);
        }

        return result.toString();
    }
}

Related

  1. getFileContents(String filePath)
  2. getFileContents(String filePath)
  3. getFileContents(String path)
  4. getFileContents(String pathToFile)
  5. getFileContents(String pFileName)
  6. readFile(String filePath)
  7. readFile(String path)
  8. readTextFile(File file, int max, String ellipsis)
  9. readTextFile(final DataInputStream is)