-
Bug
-
Resolution: Fixed
-
P3
-
7
-
b128
-
generic
-
generic
-
Verified
JDK version: 7-pro-b123
According to java doc http://download.oracle.com/javase/7/docs/api/, ZipPath.toRealPath() should always return absolute path.
The following code shows ZipPath does NOT behave so. (test code and zip file attached)
=====Begin of Code=====
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import com.sun.nio.zipfs.ZipFileSystem;
import static java.lang.System.out;
public class ToRealPath {
public static void main(String[] args) throws IOException {
String[] info = { "", "ZipPath_PathOperation_ToRealPath", "null" };
Map<String, Object> env = new HashMap<String, Object>();
Path file = Paths.get("a.zip");
ZipFileSystem fs = (ZipFileSystem) FileSystems.newFileSystem(file, env,
null);
out.println(Paths.get("a.zip").toRealPath(false));
out.println(fs.getPath("file1.txt").toRealPath(false));
out.println(fs.getPath("/file1.txt").toRealPath(false));
}
}
=====End of Code=====
=====Begin of Output=====
D:\eclipse\workspace\catch-all-7\a.zip
file1.txt
file1.txt
=====End of Output=====
According to java doc http://download.oracle.com/javase/7/docs/api/, ZipPath.toRealPath() should always return absolute path.
The following code shows ZipPath does NOT behave so. (test code and zip file attached)
=====Begin of Code=====
import java.io.IOException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map;
import com.sun.nio.zipfs.ZipFileSystem;
import static java.lang.System.out;
public class ToRealPath {
public static void main(String[] args) throws IOException {
String[] info = { "", "ZipPath_PathOperation_ToRealPath", "null" };
Map<String, Object> env = new HashMap<String, Object>();
Path file = Paths.get("a.zip");
ZipFileSystem fs = (ZipFileSystem) FileSystems.newFileSystem(file, env,
null);
out.println(Paths.get("a.zip").toRealPath(false));
out.println(fs.getPath("file1.txt").toRealPath(false));
out.println(fs.getPath("/file1.txt").toRealPath(false));
}
}
=====End of Code=====
=====Begin of Output=====
D:\eclipse\workspace\catch-all-7\a.zip
file1.txt
file1.txt
=====End of Output=====