【文件属性】:
文件名称:图片与二进制的相互转换
文件大小:2KB
文件格式:JAVA
更新时间:2019-02-17 08:00:14
image.binary
public static String getImageBinary(){
File f = new File("d://1.jpg");
BufferedImage bi;
try {
bi = ImageIO.read(f);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(bi, "jpg", baos);
byte[] bytes = baos.toByteArray();
return encoder.encodeBuffer(bytes).trim();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}