The Artima Developer Community
Sponsored Link

Java Answers Forum
Directory Conents from URL

2 replies on 1 page. Most recent reply: Sep 28, 2005 7:39 AM by rohit

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
rohit

Posts: 2
Nickname: hellsangel
Registered: Sep, 2005

Directory Conents from URL Posted: Sep 27, 2005 10:31 PM
Reply to this message Reply
Advertisement
Hi
I am using URL to get a list of a particulat directory via http port some thing like ..

String urlStr = "http://localhost:9090/logs/MEMORY.txt"
URL url = new URL(urlStr);

is it possible to get the Entire directory listing by specifying the Directory URL say

String urlStr = "http://localhost:9090/logs/
URL url = new URL(urlStr);

Or there any other way I can acieve the same.

Thanks in advace.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: Directory Conents from URL Posted: Sep 27, 2005 11:28 PM
Reply to this message Reply
I've never done this before, but I'm sure there is a
simpler solution than using URL. Pretty much the
way the JFileChooser manages to locate every file
that is in a current directory. If I were you
I would google the algorithm for JFileChooser
(it might be a dead-end though).

Here's another suggestion/question, wouldn't the
javax.naming package be capable of doing this?

rohit

Posts: 2
Nickname: hellsangel
Registered: Sep, 2005

Re: Directory Conents from URL Posted: Sep 28, 2005 7:39 AM
Reply to this message Reply
Thanks for the reply.

I found a solution for the problem actually JFileChooser works on the Local Directory. And for that purpose File Class has a the relevent APIs for the same.

The way I did it is

String urlStr = "http://localhost:9090/logs/";
URL url = new URL(urlStr);
java.net.URLConnection con = url.openConnection();
con.connect();

java.io.BufferedReader in = new java.io.BufferedReader
(new java.io.InputStreamReader(con.getInputStream()));
String line;
();
for (; (line = in.readLine()) != null; ) {
{
}
.........

This way you can get the Entire Listing.

Flat View: This topic has 2 replies on 1 page
Topic: StyleConstants.isXXX() error with JEditorPane Previous Topic   Next Topic Topic: Java Help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use