Here you can find the source of putImagePath(String imagePath)
public static byte[] putImagePath(String imagePath)
//package com.java2s; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; public class Main { public static byte[] putImagePath(String imagePath) { byte[] imageByte = null; try {//from w w w .ja v a 2 s. c o m BufferedInputStream in = new BufferedInputStream( new FileInputStream(imagePath)); ByteArrayOutputStream out = new ByteArrayOutputStream(1024); byte[] temp = new byte[1024]; int size = 0; while ((size = in.read(temp)) != -1) { out.write(temp, 0, size); } in.close(); imageByte = out.toByteArray(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return imageByte; } }