getResourceAsStream returns HttpInputStream not of the entire file

Posted by khue on Stack Overflow See other posts from Stack Overflow or by khue
Published on 2010-05-20T03:10:14Z Indexed on 2010/05/20 3:20 UTC
Read the original article Hit count: 237

Filed under:
|

Hi, I am having a web application with an applet which will copy a file packed witht the applet to the client machine.

When I deploy it to webserver and use: InputStream in = getClass().getResourceAsStream("filename") ;

The in.available() always return a size of 8192 bytes for every file I tried, which means the file is corrupted when it is copied to the client computer.

The InputStream is of type HttpInputStream (sun.net.protocol.http.HttpUrlConnection$httpInputStream). But while I test applet in applet viewer, the files are copied fine, with the InputStream returned is of type BufferedInputStream, which has the file's byte sizes. I guess that when getResourceStream in file system the BufferedInputStream will be used and when at http protocol, HttpInputStream will be used.

How will I copy the file completely, is there a size limited for HttpInputStream? Thanks a lot.

© Stack Overflow or respective owner

Related posts about java

Related posts about inputstream