简体   繁体   English

我需要Java ftpclient的什么权限?

[英]What permissions do i need for a java ftpclient?

I'm new in java and I'm working on an android app that connects to a ftp server .I'm having problems because i don't know exactly what permissions do I need to add to AndroidManifest.xml .I also have problems because I can't get it to connect to the server. 我是java的新手,我正在开发一个连接到ftp服务器的Android应用程序。我遇到了问题,因为我不知道我需要添加到AndroidManifest.xml的确切权限。我也有问题因为我无法连接到服务器。 MainActivity.java : MainActivity.java:

   package com.mycompany.myapp;
import android.app.*;
import android.os.*;
import it.sauronsoftware.ftp4j.FTPClient;
import android.widget.*;
import it.sauronsoftware.ftp4j.*;
import java.io.*;public class MainActivity extends Activity 
{
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        FTPClient client = new FTPClient();
        try
        {
            client.connect("192.168.1.1", 21);
            client.login("root", "root");
                Toast.makeText(getApplicationContext(),"Connected!",Toast.LENGTH_SHORT).show();
    }
    catch (FTPException e)
    {}
    catch (IllegalStateException e)
    {}
    catch (IOException e)
    {}
    catch (FTPIllegalReplyException e)
    {}
}

} }

AndroidManifest.xml: AndroidManifest.xml中:

    <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mycompany.myapp" >
<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

main.xml: main.xml中:

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

All you should need is INTERNET. 所有你需要的是互联网。 Although depending on what you want to do, READ_EXTERNAL_STORAGE or WRITE_EXTERNAL_STORAGE may make sense. 虽然取决于您想要做什么,但READ_EXTERNAL_STORAGE或WRITE_EXTERNAL_STORAGE可能有意义。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM