Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Not A Bug
-
2.8.0
-
None
-
None
-
Mac OS Catalina v 10.15.7
Java 11
MacBook Pro (16-inch, 2019)
Description
I run the following code
import org.apache.commons.io.IOUtils; import java.io.*; class Scratch { public static void main(String[] args) throws IOException { String oldFilePath = "your_path/test.zip"; String newFilePath = "your_path/new_zip.zip"; InputStream inputStream = new FileInputStream(oldFilePath); File file = new File(newFilePath); file.createNewFile(); IOUtils.copyLarge(inputStream, new BufferedOutputStream(new FileOutputStream(file))); } }
I then try to open the new_zip.zip and it is impossible to open, the file is not well copied
However if I remove the BufferedOutputStream as below, the copy works correctly
import org.apache.commons.io.IOUtils; import java.io.*; class Scratch { public static void main(String[] args) throws IOException { String oldFilePath = "your_path/test.zip"; String newFilePath = "your_path/new_zip.zip"; InputStream inputStream = new FileInputStream(oldFilePath); File file = new File(newFilePath); file.createNewFile(); IOUtils.copyLarge(inputStream, new FileOutputStream(file)); } }