I'm trying to rename a directory in a ZIP file using Java 7 NIO.
The zip file is very simple: it contains a "TestFolder" directory, which contains a "test.txt" file.
I want to rename TestFolder to NewFolder.
Here is my code:
public class Test {
public static void main(String[] args) {
Path test = Paths.get("C:\\myZipFile.zip");
try (FileSystem zipfsWin = FileSystems.newFileSystem(test, null)) {
Path oldFolderName = zipfsWin.getPath("/TestFolder");
Path newFolderName = zipfsWin.getPath("/NewFolder");
Files.move(oldFolderName, newFolderName);
} catch (IOException e) {
e.printStackTrace();
}
}
}
The problem is that after running this code, the TestFolder is still here, with its text file and I have a new empty NewFolder directory.
What am I missing?