Java InputStreamReader Read readFile(String filename)

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

Description

read File

License

BSD License

Declaration

public static String readFile(String filename) throws Exception 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright Duke Comprehensive Cancer Center and SemanticBits
 * /*from  ww w  .j av a 2 s . c om*/
 * Distributed under the OSI-approved BSD 3-Clause License.
 * See http://ncip.github.com/c3pr/LICENSE.txt for details.
 ******************************************************************************/

public class Main {
    public static String readFile(String filename) throws Exception {
        java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(
                Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
        StringBuffer sb = new StringBuffer();
        try {
            String newline = System.getProperty("line.separator");
            String tmp = null;
            while ((tmp = br.readLine()) != null) {
                sb.append(tmp);
                sb.append(newline);
            }
        } finally {
            if (br != null)
                br.close();
            return (sb.toString());
        }
    }
}

Related

  1. readFile(String fileFullPath)
  2. readFile(String fileName)
  3. readFile(String filename)
  4. readFile(String fileName)
  5. readFile(String filename)
  6. readFile(String fileName)
  7. readFile(String fileName)
  8. readFile(String fileName)
  9. readFile(String filename)