Java BufferedReader Read readFile(String fullPath)

Here you can find the source of readFile(String fullPath)

Description

read File

License

Open Source License

Declaration

public static String readFile(String fullPath) throws Exception 

Method Source Code


//package com.java2s;
/*//from  w  ww  .  ja  va 2s. c o  m
 * FileUtil.java
 * Copyright (C) 2007-3-19  <JustinLei@gmail.com>
 *
 *        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 2 of the License, or
 *     (at your option) 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.FileReader;

public class Main {

    public static String readFile(String fullPath) throws Exception {
        BufferedReader reader = new BufferedReader(new FileReader(fullPath));
        if (reader == null)
            return null;
        StringBuilder builder = new StringBuilder("");
        String line = null;
        while ((line = reader.readLine()) != null) {
            builder.append(line + "/n");
        }
        return builder.toString();
    }
}

Related

  1. readFile(String filePath)
  2. readFile(String filePath)
  3. readFile(String filePath)
  4. readFile(String filePath, Boolean replaceNewLineWithBr)
  5. readFile(String fullPath)
  6. readFile(String nameFile)
  7. readFile(String path)
  8. readFile(String path)
  9. readFile(String path)