方法
public static String netImgToBase64(String --------) {
DataInputStream -- = null;
HttpURLConnection ---------- = null;
String --------- = null;
try {
URL --- = new URL(--------);
---------- = (HttpURLConnection) ---.openConnection();
-- = new DataInputStream(----------.getInputStream());
ByteArrayOutputStream ------ = new ByteArrayOutputStream();
byte[] ------ = new byte[1024];
int ------;
while ((------ = --.read(------)) > 0) {
------.write(------, 0, ------);
}
Encoder ------- = Base64.getEncoder();
--------- = -------.encodeToString(------.toByteArray());
} catch (Exception -) {
-.printStackTrace();
} finally {
if (---------- != null) {
----------.disconnect();
}
if (-- != null) {
try {
--.close();
} catch (IOException -) {
-.printStackTrace();
}
}
}
String ---- = "data:image/png;base64," + ---------;
return ----;
}