在httppost图片的传输中,将图片转为base64编码传送

mac2024-08-09  53

path=数据库存放图片的路径

public static String imageToBase64(String path) { InputStream in = null; byte[] data = null; try { in = new FileInputStream(path); data = new byte[in.available()]; in.read(data); in.close(); } catch (IOException e) { e.printStackTrace(); } BASE64Encoder encoder = new BASE64Encoder(); return encoder.encode(data); }
最新回复(0)