What I need is to create a temporary folder and put inside a zip folder that already exits in my computer.
I did not found any solution or example to build this code.
I created a folder in home/myName/folderTest
(in Ubuntu). Inside this folderTest
, I create a temporary folder. Now I need to get my zip and put it inside this folder. I don't know how to do this and how to delete the temporary folder when I don't need it.
public static void main(String[] args) throws IOException {
Path rootDirectory = FileSystems.getDefault().getPath("/home/myName/folderTest");
Path tempDirectory = Files.createTempDirectory(rootDirectory, "");
String dirPath = tempDirectory.toString();
System.out.println(dirPath);
try
{
ZipFile zipFile = new ZipFile("/home/myName/zipTest.zip");
ZipParameters parameters = new ZipParameters();
zipFile.addFolder(dirPath, parameters);
}
catch (ZipException e) {
e.printStackTrace();
}
}
This code doesn't give any errors, but the zip is not copied to the temporary folder.