/***

    * @param spec 图片路径
    * @param size 
    * @return url请求结果
    */
   public static byte[] BufferStreamForByte(String spec) {
   byte[] content = null;
       try {
           BufferedInputStream bis = null;    
           ByteArrayOutputStream out = null;
           try {
               FileInputStream input=new FileInputStream(spec);
               bis = new BufferedInputStream(input, 1024);
               byte[] bytes = new byte[1024];
               int len;
               out = new ByteArrayOutputStream();
               while ((len = bis.read(bytes)) > 0) {
                   out.write(bytes, 0, len);
               }
               bis.close();
               content = out.toByteArray();
           } finally {
               if (bis != null)
                   bis.close();
               if (out != null)
                   out.close();
           }
       } catch (IOException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }
       return content;
   }
 
这是我的一点代码总结,仅供参考