Here you can find the source of readFile(String destination)
Parameter | Description |
---|---|
destination | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static byte[] readFile(String destination) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { /**// w w w.j av a 2 s . com * readFile * * @param destination * @return * @throws IOException */ public static byte[] readFile(String destination) throws IOException { File temp = new File(destination); if (temp.exists()) { FileInputStream fis = new FileInputStream(temp); byte[] data = new byte[(int) temp.length()]; try { fis.read(data); } finally { fis.close(); } return data; } return new byte[0]; } /** * existFile * * @param path * @return */ public static boolean exists(String path) { try { File temp = new File(path); return temp.exists(); } catch (Exception e) { // ignore } return false; } }