【记录】根据链接地址URL判断文件类型
判断类型的代码
try {
String report = "www.baidu.com";
URL url = new URL(report);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.connect();
BufferedInputStream bis = new BufferedInputStream(connection.getInputStream());
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int n;
while (-1 != (n = bis.read(buffer))) {
output.write(buffer, 0, n);
}
版权声明:
作者:zhangchen
链接:https://www.techfm.club/p/20915.html
来源:TechFM
文章版权归作者所有,未经允许请勿转载。
THE END
二维码
共有 0 条评论