// 通过输入流获取图片数据 InputStream inStream = conn.getInputStream(); // 读取图片字节数组 byte[] data = new byte[inStream.available()]; inStream.read(data); inStream.close(); // 对字节数组Base64编码 BASE64Encoder encoder = new BASE64Encoder(); // 返回Base64编码过的字节数组字符串 ...
importjava.io.IOException; importjava.io.InputStream; importjava.net.HttpURLConnection; importjava.net.URL; importjava.util.ArrayList; importjava.util.Base64; importjava.util.List; importjava.util.Map; publicString imageChangeBase64(String imagePath){ ByteArrayOutputStream outPut =newByteArrayOutput...
/** * 获取网络图片并转为Base64编码 * * @param url * 网络图片路径 * @return base64编码 * @throws Exception*/publicstaticString GetUrlImageToBase64(String url) throws Exception {if(url ==null||"".equals(url.trim()))returnnull; URL u=newURL(url);//打开图片路径HttpURLConnection conn ...