File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Sockets and Internet Protocols and the fly likes reading an ftp file using URLConnection Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "reading an ftp file using URLConnection" Watch "reading an ftp file using URLConnection" New topic
Author

reading an ftp file using URLConnection

san sui
Greenhorn

Joined: Feb 25, 2002
Posts: 3
I have been able to open an FTP connection
using the URLConnection class - I specify
the host as ftp://<hostname>/<filename>
fileURLCon = (URLConnection)
fileURL.openConnection();
if ( fileURLCon == null ){
return false;
sizeInBytes = fileURLCon.getContentLength();
The problem is as follows:
On Netscape I am able to get the size of the
file on calling the getContentLength method,
and am able to open a stream and read the
file in.
However, on Internet Explorer the
getContentLength returns a -1 !!
Does anyone know how to get Explorer to download
a ftp url file using URLConnection or any other
class.
It seems to me that the class
com.ms.net.wininet.WininetURLConnection that IE uses has a bug.
btw, I am using IE 5.5
Thanks a lot.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: reading an ftp file using URLConnection
 
Similar Threads
Problem while downloading an excel file in https mode
Reading from an FTP URL
ANT FTP task: Software caused connection abort: connect
Problem in downloading file from Servlet
CANNOT download file from https in IE 6