Java FileInputStream Read readFile(String path)

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

Description

read File

License

Apache License

Declaration

public static String readFile(String path) throws IOException 

Method Source Code


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

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

public class Main {
    public static String readFile(String path) throws IOException {
        File file = new File(path);
        FileInputStream fis = new FileInputStream(file);
        byte[] data = new byte[(int) file.length()];
        fis.read(data);//from   w  w  w.j  a v a 2s .  c  o m
        fis.close();
        return new String(data, "UTF-8");
    }
}

Related

  1. readFile(String path)
  2. Readfile(String path)
  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, long offset)