Ich wollte mal das neue Feature des ZIP FileSystems von Java7 testen. Interessanterweise hat das unter Linux perfekt funktioniert, hingegen unter Windows wirft das Programm eine Exception:
Das Programm:
[JAVA=1]
package testing.ziptest;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Main {
public static void main(String[] args) throws IOException {
String zipFileName = "test.zip";
if (args != null && args.length > 0) {
zipFileName = args[0];
}
FileSystem fs = FileSystems.newFileSystem(Paths.get(zipFileName), null);
Iterable<Path> roots = fs.getRootDirectories();
for (Path dir : roots) {
dirWalk(dir, 0);
}
}
private static void dirWalk(Path dir, int level) throws IOException {
if (dir == null) {
return;
}
System.out.println(" " + level + " :: " + "'" + dir.toString() + "'");
if (Files.notExists(dir)) {
return;
}
if (Files.isDirectory(dir)) {
DirectoryStream<Path> ds = Files.newDirectoryStream(dir);
for (Path child : ds) {
dirWalk(child, level + 1);
}
}
}
}
[/code]
Hier das Resultat unter Windows7:
Unter Linux läuft's bestens:
Ist das ein bekanntes Problem von Windows7? Könnte das etwas mit der Spracheinstellung von Windows zu tun haben? Eigenartigerweise habe ich nirgends einen Hinweis gefunden, dass hier Probleme vorliegen könnten. Dasselbe Resultat finde ich auch, wenn ich das entsprechende Demo Programm von ORACLE aus dem JDK teste.
Ich bin für jeden Hinweis sehr dankbar!
Das Programm:
[JAVA=1]
package testing.ziptest;
import java.io.IOException;
import java.nio.file.DirectoryStream;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class Main {
public static void main(String[] args) throws IOException {
String zipFileName = "test.zip";
if (args != null && args.length > 0) {
zipFileName = args[0];
}
FileSystem fs = FileSystems.newFileSystem(Paths.get(zipFileName), null);
Iterable<Path> roots = fs.getRootDirectories();
for (Path dir : roots) {
dirWalk(dir, 0);
}
}
private static void dirWalk(Path dir, int level) throws IOException {
if (dir == null) {
return;
}
System.out.println(" " + level + " :: " + "'" + dir.toString() + "'");
if (Files.notExists(dir)) {
return;
}
if (Files.isDirectory(dir)) {
DirectoryStream<Path> ds = Files.newDirectoryStream(dir);
for (Path child : ds) {
dirWalk(child, level + 1);
}
}
}
}
[/code]
Hier das Resultat unter Windows7:
Code:
c:\temp>java -jar ziptest.jar ziptest.jar
Exception in thread "main" java.io.IOException: Unable to get effective rights from ACL: Der Vorgang wurde erfolgreich beendet.
at sun.nio.fs.WindowsFileSystemProvider.getEffectiveAccess(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.checkAccess(Unknown Source)
at com.sun.nio.zipfs.ZipFileSystem.<init>(ZipFileSystem.java:124)
at com.sun.nio.zipfs.ZipFileSystemProvider.newFileSystem(ZipFileSystemProvider.java:139)
at java.nio.file.FileSystems.newFileSystem(Unknown Source)
at testing.ziptest.Main.main(Main.java:18)
c:\temp>
Unter Linux läuft's bestens:
Code:
pcsg:~/JavaTests/zipfile/dist $ java -jar ziptest.jar ziptest.jar
0 :: '/'
1 :: '/testing/'
2 :: '/testing/ziptest/'
3 :: '/testing/ziptest/Main.class'
1 :: '/META-INF/'
2 :: '/META-INF/MANIFEST.MF'
pcsg:~/JavaTests/zipfile/dist $
Ist das ein bekanntes Problem von Windows7? Könnte das etwas mit der Spracheinstellung von Windows zu tun haben? Eigenartigerweise habe ich nirgends einen Hinweis gefunden, dass hier Probleme vorliegen könnten. Dasselbe Resultat finde ich auch, wenn ich das entsprechende Demo Programm von ORACLE aus dem JDK teste.
Ich bin für jeden Hinweis sehr dankbar!
Zuletzt bearbeitet: