1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
public static ByteArrayOutputStream getOutputStream(String filePath){ File file = new File(filePath); FileInputStream in = null; ByteArrayOutputStream out = new ByteArrayOutputStream(); try { in = new FileInputStream(file); byte[] buffer = new byte[in.available()]; in.read(buffer); out.write(buffer); } catch (Exception e) { e.printStackTrace(); }finally{ try { if(in!=null) in.close(); } catch (Exception e2) { } } return out; } |