File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How do I read multiple files in one directory from URL?

 
Alan Blass
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!

I have multiple files in a directory and I want to send it as an email attachment:

Eg:

http://www.mysite.com/myDirectory/

contains file1.txt, file2.txt.

I know how to attach it in an email. I just don't know how to read the files from the directory and pass it into:

URL url = new URL("http://www.mysite.com/myDirectory/");

File file = new File(url);

Please help. Thanks.
 
Ulf Dittmer
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would likely not use a File, but work with an InputStream - which you can get via url.openStream().
 
Alan Blass
Ranch Hand
Posts: 156
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. Thanks for your reply.

Is it possible to list the files in that directory?Because the filenames in that directory is unknown.

Thanks.
 
Paul Clapham
Sheriff
Pie
Posts: 20171
24
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by "that directory". What you showed us so far is an HTTP URL, and those can't be used to represent a directory.
 
Robert D. Smith
Ranch Hand
Posts: 201
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure if what you want can be done. But I would start with the URLConnection class.

Regards,
Robert
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic