Java Text File Load loadTextFile(String fileFullPath)

Here you can find the source of loadTextFile(String fileFullPath)

Description

load Text File

License

Open Source License

Declaration

public static String loadTextFile(String fileFullPath) 

Method Source Code

//package com.java2s;
/*//from   w  w  w.j a  v a  2 s  . c  om
 * DVFileUtil.java  2/9/13 1:39 PM
 *
 * Copyright (C) 2012-2013 Nick Ma
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

import java.io.BufferedReader;

import java.io.File;

import java.io.FileReader;

public class Main {
    public static String loadTextFile(String fileFullPath) {

        StringBuffer text = new StringBuffer();
        BufferedReader input;
        try {
            File f = new File(fileFullPath);
            input = new BufferedReader(new FileReader(f));

            while (input.readLine() != null) {
                text.append(input.readLine() + "\n");
            }
            input.close();

        } catch (Exception ioe) {
            return ioe.getMessage();
        }
        return text.toString();

    }
}

Related

  1. loadText(String path)
  2. loadText(String path)
  3. loadTextFile(File file)
  4. loadTextFile(File textFile)
  5. loadTextFile(final String filePath)
  6. loadTextFile(String fileName)
  7. loadTextFile(String filename)
  8. loadTextFile(String fileName)
  9. loadTextFile(String filename, int maxLines)