まず第一に - これは私が StackOverflow で尋ねる最初の質問です。そして、私はドイツ出身で、私の英語はあまり上手ではありません:)
FTP クライアントを Android アプリとして作成しようとしています。私はEclipseとAndroid SDKでコーディングしています。
これは私のコードですが、機能しません。私は Apache Commons FTP Library を使用しています。手伝って頂けますか?機能的なコードは必要ありませんが、コードを機能させるためのアドバイスを得るのが大好きです。ありがとう!
だからここに私のコードがあります:
import org.apache.commons.net.ftp.FTPClient;
public class speechatStart extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
Button b1 = (Button) findViewById(R.id.bt_load);
b1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
FTPClient client = new FTPClient();
TextView ausgabe = (TextView) findViewById(R.id.ausgabe);
try {
client.connect("ftp-web.ohost.de");
client.login("ftp1857836", "123456789");
String filename = "file1.txt";
FileInputStream fis = null;
fis = new FileInputStream(filename);
client.storeFile(filename, fis);
client.logout();
fis.close();
ausgabe.setText(fis);
} catch (SocketException e) {
// TODO Auto-generated catch block
e.printStackTrace();
ausgabe.setText("SocketException");
} catch (IOException e) {
// TODO Auto-generated catch block
ausgabe.setText("IOException");
}
}
});