Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Getting a list of files at URL

  1. #1
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Getting a list of files at URL

    I have a quick question. I have a directory on a web server (which I have ftp access to) and I'm trying to get a list of the documents in that directory (perhaps just a String Array of their names). Is this possible and, if so, how do I do it?

    Cheers
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Getting a list of files at URL

    Do you have code to connect to the FTP server? Getting a list of files in a dir is reasonably easy.

    Have you looked at Apache's Common FTP library?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Getting a list of files at URL

    Yep. Connecting to the FTP server is no problem. I know how to get a list of files on a local computer (using the File class), but not how to get a list of files on a server directory.

    Is this the sort of thing that can be done without exterior libraries? I'm wanting to minimize dependencies.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Getting a list of files at URL

    If you don't want to use the Apache library, FTP is not too complicated, you could write your own FTP client.
    The library will be easier.

  5. #5
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Getting a list of files at URL

    Well I don't exactly need anything too excessive. All I'm wanting to do is get a list of the names of the x number of files in a server directory so I can read/write to them later on. I need to get a list in the code because the number of files will change between executions of the program. Also, on that note, how would I go about creating a new file in a directory. I know how to read and write from already existing files, but creating a new file is something I've never done.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Getting a list of files at URL

    Read up on how FTP works. Its written up in a RFC

Similar Threads

  1. Java program which can list all files in a given directory
    By JavaPF in forum Java Programming Tutorials
    Replies: 8
    Last Post: July 9th, 2013, 03:38 AM
  2. Replies: 1
    Last Post: March 22nd, 2011, 06:59 PM
  3. Moving files to a single list iteratively
    By Growler in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: October 22nd, 2010, 10:08 AM
  4. Getting List of Files Within Jar
    By aussiemcgr in forum Java Theory & Questions
    Replies: 1
    Last Post: October 13th, 2010, 09:38 AM
  5. Java program which can list all files in a given directory
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 5
    Last Post: November 3rd, 2009, 09:42 AM