Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.    
  2.  
  3. Im working with FTP4J java api and android in eclipse.
  4.  
  5. I am a newbie.
  6.  
  7. I am trying to populate a ListView with some files of the working directory on an ftp server.
  8.  
  9.     FTPClient client;
  10.         FTPFile[] list;
  11.  
  12.         client.connect("100.100.100.100");
  13.         client.login(usernamestring, passwordstring);
  14.         list = client.list();               //this line returns the files in the current directory
  15.  
  16.         String lv_arr[]={list[0].getname(),list[1].getname(),list[2].getname()};    //this is where the program crashes
  17.  
  18.         final ListView filelist = (ListView) findViewById(R.id.ListView01);
  19.  
  20.         filelist.setAdapter(new ArrayAdapter<String>(ftpclientbasic.this,
  21.                 android.R.layout.simple_list_item_1, lv_arr));
  22.  
  23.  
  24.  
  25. The program always crashes when I try to populate the string array with some elements of the FTPFile (list) object.
  26.  
  27. If i populate the string array manually with String lv_arr[]={"example","example"} it works fine, i see "example example" in the list view. Where am i going wrong?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement