public static String getImageString(String file_path) throws IOException {
InputStream in = null;
byte[] data = null;
try {
if (file_path.indexOf("http") > -1) {
URL url_f = new URL(file_path);
in = url_f.openStream();
} else {
in = new FileInputStream(file_path);
}
data = new byte[in.available()];
in.read(data);
in.close();
} catch (IOException e) {
throw e;
} finally {
if (in != null) in.close();
}
BASE64Encoder encoder = new BASE64Encoder();
return data != null ? encoder.encode(data) : "";
}
QQ交流群:201455739 (java/mysql/nginx/minio)