Java Text File Load loadTextFile(final String filePath)

Here you can find the source of loadTextFile(final String filePath)

Description

load Text File

License

Open Source License

Declaration

public static String loadTextFile(final String filePath)
            throws IOException 

Method Source Code

//package com.java2s;
/*/* www.ja  v a2 s .  com*/
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */

import java.io.BufferedReader;

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

public class Main {
    public static String loadTextFile(final String filePath)
            throws IOException {
        final FileReader fileReader = new FileReader(filePath);
        final BufferedReader bufReader = new BufferedReader(fileReader);

        String line = null;
        final StringBuilder result = new StringBuilder();
        while ((line = bufReader.readLine()) != null) {
            result.append(line);
        }
        bufReader.close();
        return result.toString();
    }
}

Related

  1. loadText(String fname)
  2. loadText(String path)
  3. loadText(String path)
  4. loadTextFile(File file)
  5. loadTextFile(File textFile)
  6. loadTextFile(String fileFullPath)
  7. loadTextFile(String fileName)
  8. loadTextFile(String filename)
  9. loadTextFile(String fileName)