Java FileInputStream Read readFile(File file)

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

Description

read File

License

Apache License

Declaration

public static String readFile(File file) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

public class Main {
    public static String readFile(File file) throws IOException {
        int nread;
        byte buf[] = new byte[8192];
        String content = "";

        FileInputStream fis = new FileInputStream(file);
        while ((nread = fis.read(buf)) != -1) {
            content += new String(buf, 0, nread);
        }/* www .jav  a2s  .  c  o m*/
        fis.close();
        return content;
    }
}

Related

  1. readFile(File file)
  2. readFile(File file)
  3. readFile(File file)
  4. readFile(File file)
  5. readFile(File file)
  6. readFile(File file, boolean compress)
  7. readFile(File file, int size)
  8. readFile(File file, OutputStream output)
  9. readFile(File file, String encoding)