Java InputStreamReader Read readFile(File f)

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

Description

read File

License

Open Source License

Declaration

public static String readFile(File f) throws IOException 

Method Source Code


//package com.java2s;
import java.io.File;
import java.io.FileInputStream;

import java.io.IOException;

import java.io.InputStreamReader;
import java.io.Reader;

public class Main {
    public static String readFile(File f) throws IOException {
        StringBuilder result = new StringBuilder();
        Reader in = null;/*from   www  .j a  va 2  s.  c o m*/

        try {
            in = new InputStreamReader(new FileInputStream(f), "utf-8"); //$NON-NLS-1$
            int c = 0;
            while ((c = in.read()) >= 0) {
                result.append((char) c);
            }
        } finally {
            if (in != null) {
                in.close();
            }
        }
        return result.toString();
    }
}

Related

  1. readFile(ClassLoader classloader, String filename)
  2. readFile(File f)
  3. readFile(File f)
  4. readFile(File f)
  5. readFile(File f)
  6. readFile(File file)
  7. readFile(File file)
  8. readFile(File file)
  9. readFile(File file)