This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Convert a to Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Convert a to" Watch "Convert a to" New topic

Convert a to

Christian Nicoll
Ranch Hand

Joined: Mar 09, 2008
Posts: 106

i'm looking for a solution, to convert a URL to a File. I need to copy files which are located on a remote server (http://...) to a local folder.

I'm able to copy single files from the remote HTTP-server to my local machine. I received a BufferedReader over the InputStream of the URL.

The rest is only a normal copy like it is used for two local files.

My problem is that I need to copy not only a single file, but a whole folder with all subfolders and files recursively. Normally this is a simple operation with the class, but this class does only work for files and folders that are located in the local filesystem.

If 've found with the forum search similar threads about this problem, but no thread gives an sufficient answer on this question. I hope that this thread will give one.

Best regards,
Christian Nicoll

My SCBCD-Notes - My Hello World Webservice
Rob Spoor

Joined: Oct 27, 2005
Posts: 19651

By default, HTTP does not allow browsing through the remote file system. Therefore, given a URL, it's by default impossible to get all "sub URLs".

Some browsers allow browsing a folder if there is no default document for that folder*, but even then that is an HTML page which you will need to parse.

Is it perhaps possible to use FTP instead of HTTP? Because FTP does allow for listing folder contents.

* If there is no default document, the browser can still give you a "directory listing not allowed" page.

How To Ask Questions How To Answer Questions
Christian Nicoll
Ranch Hand

Joined: Mar 09, 2008
Posts: 106
Hi Rob,

thanks for your fast answer. I will have to look for another solution.

I agree. Here's the link:
subject: Convert a to
Similar Threads
Run Servlet In Eclipse
Escaping the forward slash while creating a remote file object.
downloading zip files from a site to local disk(urgent please)
ftp question
File access from an applet