Here you can find the source of getBytes(String fileUrl)
public static byte[] getBytes(String fileUrl)
//package com.java2s; //License from project: Open Source License import java.io.File; import java.io.FileInputStream; import java.io.IOException; public class Main { public static byte[] getBytes(String fileUrl) { File file = new File(fileUrl); if (!file.exists()) { return null; }// ww w . j a va2 s . c om FileInputStream io = null; byte[] data = null; try { io = new FileInputStream(file); data = new byte[io.available()]; io.read(data); } catch (IOException e) { e.printStackTrace(); } finally { if (null != io) { try { io.close(); } catch (IOException e2) { e2.printStackTrace(); } } } return data; } /** * 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; } }