保存到本地在操作真心感觉麻烦
public static byte[] getHtmlByteArray(final String url) {
URL htmlUrl = null;
InputStream inStream = null;
try {
htmlUrl = new URL(url);
URLConnection connection = htmlUrl.openConnection();
HttpURLConnection httpConnection = (HttpURLConnection) connection;
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
inStream = httpConnection.getInputStream();
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
// 将io流转为byte数组
byte[] data = inputStreamToByte(inStream);
if (data.length > ‘耀’) {
// 转换为bitmap
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
// 获取压缩后的byte数组
data = compressB