Java FileInputStream Read readFile(String filename)

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

Description

read File

License

Open Source License

Declaration

static public byte[] readFile(String filename) throws IOException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

import java.io.IOException;

public class Main {
    static public byte[] readFile(String filename) throws IOException {
        File file = new File(filename);
        long len = file.length();
        byte data[] = new byte[(int) len];
        FileInputStream fin = new FileInputStream(file);
        int r = fin.read(data);
        if (r != len)
            throw new IOException("Only read " + r + " of " + len + " for "
                    + file);/*w  w w.j  ava 2 s . c  o  m*/
        fin.close();
        return data;
    }
}

Related

  1. readFile(String filename)
  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)