Advertisement
Guest User

Untitled

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