int length = 0;
URL url;
try {
url = new URL(url1);
HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();
//根据响应获取文件大小
length = urlcon.getContentLength();
urlcon.disconnect();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return length;
}
/**
-
从输入流中获取字节数组
-
@author Jayvee
-
@param inputStream
-
@return
-
@throws IOException
*/
public static byte[] readInputStream(InputStream inputStream) throws IOException {
byte[] buffer = new byte[1024];
int len = 0;
ByteArrayOutputStream bos = new ByteArrayOutputStream();