读取Api接口的压缩文件

// 读取api接口的压缩文件
// HttpResponse res = 调取的api
InputStream inputStream = res.bodyStream();
// String zipPath = System.getProperty("user.dir") + "/***.zip" // 重名时会覆盖,当前目录下的此文件
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
FileOutputStream fileOutputStream = new FileOutputStream(zipPath);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fileOutputStream);
byte[] buf = new byte[4096];
int length = bufferedInputStream.read(buf);
while (-1 != length){
    bufferedOutputStream.write(buf,0,length);
    length = bufferedInputStream.read(buf);
}
bufferedInputStream.close();
bufferedOutputStream.close();

你可能感兴趣的:(工作代码,java,开发语言,后端)