Name: dbT83986 Date: 04/29/99
getContentType() of JarURLConnection (the one under sun.net.*) isn't returning a valid content type for .java files; shouldn't getContentType() recognize .java source files?
The following
import java.security.*;
import java.io.*;
import java.net.*;
class test {
public test() {}
public static void main(String args[]) {
try {
URL u = new URL("jar:file:/c://temp//test.jar!/test.java");
JarURLConnection uc = (JarURLConnection)u.openConnection();
//System.out.println(uc.getInputStream());
System.out.println(uc.getContentType());
} catch (Exception e) {
System.out.println("error here");
e.printStackTrace();
}
}
}
returns null. In fact it returns null as long as that URL does not refer to a JarFile (JarEntry is null).
In the case where it is refering to a JarFile, it returns "x-java/jar"
Since the generic getContent() uses getContentType() to find the right content handler, this leads to another problem:
If getContent() is called in the test case above, it will raise an UnknownServiceException saying no content-type. I
suspect it is due to the null returned by getContentType()
(Review ID: 57640)
======================================================================
- relates to
-
JDK-4243169 java.util.jar.JarEntry constructor JarEntry(String name) causes exception.
-
- Closed
-