Java InputStreamReader Read readFile(String f)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(String f) throws IOException 

Method Source Code

//package com.java2s;
// copyright 2009 ActiveVideo; license: MIT; see license.txt

import java.io.*;

public class Main {
    public static String readFile(String f) throws IOException {
        InputStreamReader in = null;
        try {//w  w  w .jav  a 2s  . c om
            StringBuilder sb = new StringBuilder();
            in = new InputStreamReader(new FileInputStream(f), "UTF-8");

            int count = 0;
            char[] buf = new char[1024 * 10];
            while ((count = in.read(buf, 0, buf.length)) > -1)
                sb.append(buf, 0, count);

            return sb.toString();
        } finally {
            try {
                if (in != null)
                    in.close();
            } catch (Exception ex) {
            }
        }
    }
}

Related

  1. readFile(InputStream is)
  2. readFile(InputStream location)
  3. readFile(InputStream stream, StringBuilder builder)
  4. readFile(Reader simpleReader)
  5. readFile(String aFile)
  6. readFile(String f, String delim)
  7. readFile(String file)
  8. readFile(String file)
  9. readFile(String file)