Java InputStreamReader Read readFile(String path)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String path) throws IOException 

Method Source Code

//package com.java2s;
/**//from  w w w.ja  va2  s  .  co m
 * Sketch Outline provides a tree view of a sketch and its 
 * members functions, variables and inner classes. Clicking on any 
 * node moves the cursor to its definition.
 *
 * Copyright (c) 2012 Manindra Moharana
 *
 * ##copyright##
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library 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
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General
 * Public License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA  02111-1307  USA
 *  
 * 
 * @author   Manindra Moharana   ##author##
 * @modified 19-03-2012         ##date##
 * @version 0.1.5 (beta)      ##version##
 */

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static String readFile(File file) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                new FileInputStream(file)));
        try {
            StringBuilder ret = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                ret.append(line);
                ret.append("\n");
            }
            return ret.toString();
        } finally {
            reader.close();
        }
    }

    public static String readFile(String path) throws IOException {
        return readFile(new File(path));
    }
}

Related

  1. readFile(String nomeFile)
  2. readFile(String p_filename)
  3. ReadFile(String Path)
  4. readFile(String path)
  5. readFile(String path)
  6. readFile(String path)
  7. readFile(String Path)
  8. readFile(String path)
  9. readFile(String path)