그래서 저는 상당히 익숙하며, 내 응용 프로그램은 계속 충돌합니다. 나는이 코드를 여기에서 발견하고 그것을 나 자신의 삶을 위해 일하도록 얻을 수 없다. 내가 뭘 하려는지 단지 선택한 파일을 다운로드하고, 내가 작업 폴더의 하위 디렉토리에 있지 않을 때 작동합니다. MySQL 데이터베이스에서 작업 폴더 이름을 다운로드하면 제대로 작동합니다. 모든 작업은 다음 ..비동기 작업 치명적인 예외 - 잡히지 않은 예외로 스레드가 종료됩니다.
4131/cdgjkg.png 4131/기타 말해 내가 일 4131이 ... 등 사진, 문서, 기타, 하위 폴더가 있습니다 .. 그리고 4131 내부가 4131/사진
사진의 내부에는 또 다른 png가 있습니다. (4131/사진/dioghg.png). 문제는 PNG wndin 기본 4131 메서드를 다운로드하면 작동합니다. 오류 없음. Photots 디렉토리에 들어가서 그 파일을 다운로드하려고하면 수많은 비동기 오류가 발생합니다. 아래는 코드입니다. 더 많이 볼 필요가 있으면 알려주세요.
new LoadAllJobs().execute();
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String file = ((TextView)view).getText().toString();
String current_dir = dir + "/" + file;
if(file.contains(".")){
//download the file or view it
try {
Log.d("Downloading ", file);
new FTPDownload().execute(file); // <-----This is where I start the task to enter the FTPDownload, never to be seen again :(
Log.d("Success ", current_dir);
}
catch (Exception e) {
e.printStackTrace();
}
이 나는 목록을 검색하고 그것이 포함 된 경우 파일 다운로드 ahve 덩어리이다 '를.' ('.'문자는 서버에 폴더 이름으로 허용되지 않으므로 빠른 속임수입니다.)
FTPDownload 클래스
class FTPDownload extends AsyncTask<String, Integer, String> {
//public FTPClient client;
@Override
protected String doInBackground(String... filename) {
try {
System.out.println("Filename->: " + filename[0]);
GetFileFTP("/" + filename[0], Environment.getExternalStorageDirectory() + "/Download/", filename[0]);
}
finally
{
//e.printStackTrace();
Log.v("DONE: ", "All done!");
}
System.out.println("I HATE YOU."); // <----- NEVER REACHES THIS LINE WHEN TRYING TO DOWNLOAD IN A SUBFOLDER
return null;
}
public void GetFileFTP(String srcFileSpec, String destpath, String destname) {
FTPClient client = new FTPClient();
Log.v("pathSpec: ", destpath);
try {
client.connect("xxxxxx");
client.login("xxxxxx", "xxxxxx");
client.enterLocalPassiveMode();
client.setFileType(org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE);
InputStream input = client.retrieveFileStream(srcFileSpec);
if(input != null) Log.v("GetFileFTP: ", "INPUT STREAM OPENED SUCCESSFULLY!");
Log.v("File InputStream: ", srcFileSpec);
File output_file = new File(destpath + destname);
Log.v("OUTPUTFILE: ", destpath + destname);
inputstreamcopy(input, output_file);
/*try {
//Log.e("Closing connection: ", client.toString());
client.logout();
client.disconnect();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
}
catch (IOException e) {
Log.e("FTP", "Error Getting File");
e.printStackTrace();
}
}
public static void inputstreamcopy(InputStream source, File destination){
try {
org.apache.commons.io.FileUtils.copyInputStreamToFile(source, destination);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
콘솔 출력
04-08 15:10:05.010: D/Downloading(29309): login.php
04-08 15:10:05.010: D/Success(29309): 4131/Miscellaneous/login.php
04-08 15:10:05.010: I/System.out(29309): Filename->: login.php
04-08 15:10:05.020: V/pathSpec:(29309): /storage/emulated/0/Download/
04-08 15:10:06.010: V/File InputStream:(29309): /login.php
04-08 15:10:06.020: V/OUTPUTFILE:(29309): /storage/emulated/0/Download/login.php
04-08 15:10:06.030: V/DONE:(29309): All done!
04-08 15:10:06.030: W/dalvikvm(29309): threadid=11: thread exiting with uncaught exception (group=0x418f5930)
04-08 15:10:06.040: E/AndroidRuntime(29309): FATAL EXCEPTION: AsyncTask #1
04-08 15:10:06.040: E/AndroidRuntime(29309): java.lang.RuntimeException: An error occured while executing doInBackground()
04-08 15:10:06.040: E/AndroidRuntime(29309): at android.os.AsyncTask$3.done(AsyncTask.java:299)
04-08 15:10:06.040: E/AndroidRuntime(29309): at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
04-08 15:10:06.040: E/AndroidRuntime(29309): at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
04-08 15:10:06.040: E/AndroidRuntime(29309): at java.util.concurrent.FutureTask.run(FutureTask.java:239)
04-08 15:10:06.040: E/AndroidRuntime(29309): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
04-08 15:10:06.040: E/AndroidRuntime(29309): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
04-08 15:10:06.040: E/AndroidRuntime(29309): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
04-08 15:10:06.040: E/AndroidRuntime(29309): at java.lang.Thread.run(Thread.java:856)
04-08 15:10:06.040: E/AndroidRuntime(29309): Caused by: java.lang.NullPointerException
04-08 15:10:06.040: E/AndroidRuntime(29309): at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1792)
04-08 15:10:06.040: E/AndroidRuntime(29309): at org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:1769)
04-08 15:10:06.040: E/AndroidRuntime(29309): at org.apache.commons.io.IOUtils.copy(IOUtils.java:1744)
04-08 15:10:06.040: E/AndroidRuntime(29309): at org.apache.commons.io.FileUtils.copyInputStreamToFile(FileUtils.java:1512)
04-08 15:10:06.040: E/AndroidRuntime(29309): at com.example.tdsi.FTPDownload.inputstreamcopy(FTPDownload.java:70)
04-08 15:10:06.040: E/AndroidRuntime(29309): at com.example.tdsi.FTPDownload.GetFileFTP(FTPDownload.java:51)
04-08 15:10:06.040: E/AndroidRuntime(29309): at com.example.tdsi.FTPDownload.doInBackground(FTPDownload.java:21)
04-08 15:10:06.040: E/AndroidRuntime(29309): at com.example.tdsi.FTPDownload.doInBackground(FTPDownload.java:1)
04-08 15:10:06.040: E/AndroidRuntime(29309): at android.os.AsyncTask$2.call(AsyncTask.java:287)
04-08 15:10:06.040: E/AndroidRuntime(29309): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
04-08 15:10:06.040: E/AndroidRuntime(29309): ... 4 more
라인 70은 무엇입니까? 뭔가 'null'입니다. 아마도'filename' – codeMagic