0

I want to read content files in the url without using ftp connection. I have more images in the site http://somedomain.com/images as photo1.png, photo2.png and etc.,

I want to read these name of the image through my coding. By using these i wiil get these. But how do i get funny1.png, funny2.png and etc.,..

<li><a href="funny1.png"> funny1.png</a></li>
 <li><a href="funny10.png"> funny10.png</a></li>
 <li><a href="funny2.png"> funny2.png</a></li>
 <li><a href="funny3.png"> funny3.png</a></li>
 <li><a href="funny4.png"> funny4.png</a></li>
 <li><a href="funny5.png"> funny5.png</a></li>
 <li><a href="funny6.png"> funny6.png</a></li>
<li><a href="funny7.png"> funny7.png</a></li>
<li><a href="funny8.png"> funny8.png</a></li>
<li><a href="funny9.png"> funny9.png</a></li>
</ul>
 </body></html>
Community
  • 1
  • 1
Shalini
  • 1,733
  • 4
  • 17
  • 31
  • You have to some index file at your server side which one has list of images for current image directory. And read this index.html file. – user370305 Jun 13 '12 at 06:05
  • Instead of server like these http://stackoverflow.com/questions/2075836/read-contents-of-a-url-in-android. It not possible?? – Shalini Jun 13 '12 at 06:09
  • Yes, the same thing.. which I mentioned in my above comment is index,html file concept.. If your web directory path contains this file then you can read this file using the question's answer you mentioned in your comment.. – user370305 Jun 13 '12 at 06:16
  • 1
    If you can manage the url(The site) then to change url output to return a json or xml of the image files.That will be the easiest way. – Stack User 5674 Jun 17 '12 at 15:10

3 Answers3

0

You would have to have some code on the server that generates the file list for you, unless you run an apache server and you don't have an index.html file. In that case, the url "http://somedomain.com/images would return a list of files, which you can read in your app. You'd have to interpret the html in order to get a plain list of files.

Christine
  • 5,617
  • 4
  • 38
  • 61
  • By java coding,it is not possible?? – Shalini Jun 13 '12 at 05:55
  • As I said, if the server doesn't publish the list of files (like when there's no index.html file), there is no way of getting the list of files without having some code on the server. If there would be a way of doing that, you could explore all servers and get file lists off them, which most admin's wouldn't like at all. – Christine Jun 13 '12 at 07:26
0

Use Sardine java library.

Sardine sardine = SardineFactory.begin(Username, Password);
List <> ph = sardine.getResource(url);
VICKY-TSC
  • 405
  • 2
  • 5
  • 19
0

I don't know, this is what you need, (Or its help you or not)

Commons VFS provides a single API for accessing various different file systems. It presents a uniform view of the files from various different sources, such as the files on local disk, on an HTTP server, or inside a Zip archive.

http://commons.apache.org/vfs/

Try this, and let me know what happen..

EDIT:

To get img tag content from HTML content look at these SO Question :

Regular expression to get an attribute from HTML tag

Parse HTML in Android

android java get html image tag from string

Java : HTML Parsing

Community
  • 1
  • 1
user370305
  • 108,599
  • 23
  • 164
  • 151