您需要创建新文件并将内容复制
InputStream到该文件:
File file = //...try(OutputStream outputStream = new FileOutputStream(file)){ IOUtils.copy(inputStream, outputStream);} catch (FileNotFoundException e) { // handle exception here} catch (IOException e) { // handle exception here}我使用方便
IOUtils.copy()来避免手动复制流。它还具有内置缓冲。



