开发者

How to upload file through FTP in Android

I want to upload xml file to through ftp from android sdcard folder, I'm trying this code to connect to ftp:

      FTPClient f开发者_JAVA技巧 = new FTPClient();
      f.connect(server,21);
      f.login(username,password);
      Log.d("status",f.getStatus());
      f.logout(); 
      f.disconnect();    

but I getting exception

Exception:

java.net.SocketException: Permission denied


Make sure you have requested the INTERNET permission in the AndroidManifest.xml file using a <uses-permission> element as shown below:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="apt.tutorial.two" android:versionCode="1" android:versionName="1.0">
    <uses-permission android:name="android.permission.INTERNET"/>
        <application android:label="@string/app_name">
                <activity android:name=".Patchy" 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>
  <supports-screens android:largeScreens="true" android:normalScreens="true" android:smallScreens="true" android:anyDensity="true"/>
</manifest>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜