0

I need to read all directory file links and I do this

File mfile=new File("http://192.168.1.86/web/ServerSideImages/Actualities/3/");
File[] list=mfile.listFiles();

System.out.println("list"+mfile.listFiles().length);
for(int i=0;i<mfile.listFiles().length;i++)
{
   System.out.println("hidden path files.."+list[i].getAbsolutePath()); 
}

but in logcat it says java.lang.NullPointerException where is my mistake please

John Willemse
  • 6,608
  • 7
  • 31
  • 45
slama007
  • 1,273
  • 2
  • 18
  • 34

1 Answers1

1

Here are your problems (mainly misunderstandings):

  • File does not work for files in the network
  • Even if File worked for that, the list at the url is likely just a html list, so:

Here is what to do:

  • Have a look at HTTPClient to get the html list at the url (Also make sure to do that in a background thread - AsyncTask will help)
  • Have a look at this on how to parse an html
Community
  • 1
  • 1
FD_
  • 12,947
  • 4
  • 35
  • 62