Java FileInputStream Read readFile(String file)

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

Description

read File

License

Open Source License

Declaration

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

Method Source Code


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

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;

public class Main {
    public static byte[] readFile(String file) throws IOException {
        FileInputStream fis = new FileInputStream(file);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        byte[] buff = new byte[1024];
        int read;
        while ((read = fis.read(buff)) != -1) {
            baos.write(buff, 0, read);/*from w ww . j ava  2  s.c om*/
        }
        baos.flush();
        fis.close();
        byte[] dat = baos.toByteArray();
        baos.close();
        return dat;
    }
}

Related

  1. readFile(InputStream iStream)
  2. readFile(String destination)
  3. readFile(String file)
  4. readFile(String file)
  5. readFile(String file)
  6. readFile(String file)
  7. readFile(String file)
  8. readFile(String filename)
  9. readFile(String fileName)