Here you can find the source of readFile(File fyl)
Parameter | Description |
---|---|
fyl | the file to read from. |
Parameter | Description |
---|---|
FileNotFoundException | , IOException if something goes wrong. |
public synchronized static byte[] readFile(File fyl) throws FileNotFoundException, IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { /**// w w w . java 2s . c om * Read a file. * @param fyl the file to read from. * @return the byte array contents of the file. * @throws FileNotFoundException, IOException if something goes wrong. */ public synchronized static byte[] readFile(File fyl) throws FileNotFoundException, IOException { int len = (int) fyl.length(); byte[] bfr = new byte[len]; BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fyl)); bis.read(bfr, 0, len); bis.close(); return bfr; } }