import java.io.*;
import java.net.*;
public class URLbug {
URL u;
URLConnection urlc;
public static void main(String args[]) {
URLbug ub = new URLbug();
}
public URLbug() {
try{
int len;
u = new URL("file:/net/java3d/export/java3d/builds/daily/README");
urlc = u.openConnection();
urlc.connect();
// uncomment to see workaround
// urlc.getContentType();
len = urlc.getContentLength();
if (len<0) {
System.out.println(len+"not a valid length");
} else {
System.out.println(len+"bytes");
}
} catch (IOException ioe) { ioe.printStackTrace(); }
}
}
This doesn't seem to affect http protocol urls.
import java.net.*;
public class URLbug {
URL u;
URLConnection urlc;
public static void main(String args[]) {
URLbug ub = new URLbug();
}
public URLbug() {
try{
int len;
u = new URL("file:/net/java3d/export/java3d/builds/daily/README");
urlc = u.openConnection();
urlc.connect();
// uncomment to see workaround
// urlc.getContentType();
len = urlc.getContentLength();
if (len<0) {
System.out.println(len+"not a valid length");
} else {
System.out.println(len+"bytes");
}
} catch (IOException ioe) { ioe.printStackTrace(); }
}
}
This doesn't seem to affect http protocol urls.
- relates to
-
JDK-1257160 getContentLength in URLConnection does not work
-
- Closed
-