commons-net-3.1 ライブラリを使って簡単なアプリケーションを作っています FTP サーバーからファイルをダウンロードしたいのですが、ダウンロードしたファイルのサイズが 0 です このファイル名には英語、記号 ("-"、"_" など)、その他が混在しています言語 (韓国語、日本語など)。この問題を解決するには?TT
ここにコードがあります
/**
* download file. it works thread
*
* @param source
* file path witch is remote path
* @param destination
* file path witch is saving local memory
*/
public void downloadFile(String source, String destination) {
DownloadTempFile download = new DownloadTempFile(source, destination);
download.setDaemon(true);
download.start();
}
class DownloadTempFile extends Thread {
String source, destination;
public DownloadTempFile(String source, String destination) {
this.source = source;
this.destination = destination;
}
public void run() {
OutputStream output = null;
try {
File local = new File(destination);
output = new FileOutputStream(local);
ftpClient.retrieveFile(source, output);
} catch (Exception e) {
// TODO: handle exception
}
}
}
そして、このコードは上位メソッドの呼び出しです
String tempPath = mSDpath + "/mgtec/temp";
File d = new File(tempPath);
if (d.isDirectory()) {
String tempFile = tempPath + "/tmp" + position + ".mp3";
NativeMusicAppActivity.mConnector.downloadFile(mAdapter
.getItem(position).toString(), tempFile);
} else {
if (d.mkdirs()) {
String tempFile = tempPath + "/tmp" + position + ".mp3";
NativeMusicAppActivity.mConnector.downloadFile(mAdapter
.getItem(position).toString(), tempFile);
}
}