图片转base64,,public stati
分享于 点击 39171 次 点评:21
图片转base64,,public stati
public static String GetImageStr(File img) { byte[] data = null; // 读取图片字节数组 try { InputStream in = new FileInputStream(img); data = new byte[in.available()]; in.read(data); in.close(); } catch (IOException e) { e.printStackTrace(); } // 对字节数组Base64编码 BASE64Encoder encoder = new BASE64Encoder(); return encoder.encode(data);// 返回Base64编码过的字节数组字符串}//该片段来自于http://byrx.net
用户点评