Java 如何连接到给定的FTP服务器并使用Android重命名文件夹中的最后一个文件?

Java 如何连接到给定的FTP服务器并使用Android重命名文件夹中的最后一个文件?,java,android,ftp,Java,Android,Ftp,连接到FTP服务器时出现以下错误 I/编舞:跳过63帧!应用程序可能在其主线程上做了太多工作。 我希望我的Android应用程序读取FTP服务器上的所有现有文件,并重命名现有文件 以下是main活动代码: public class MainActivity extends AppCompatActivity { public FtpConnection ftpp; @Override protected void onCreate(Bundle savedInstan

连接到FTP服务器时出现以下错误

I/编舞:跳过63帧!应用程序可能在其主线程上做了太多工作。

我希望我的Android应用程序读取FTP服务器上的所有现有文件,并重命名现有文件

以下是
main活动
代码:

public class MainActivity extends AppCompatActivity {
    public FtpConnection ftpp;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

         ftpp=new FtpConnection(this);
        final TextView textView=(TextView)findViewById(R.id.textView);



        Button button=(Button)findViewById(R.id.btn);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean result= ftpConnect();
                if (result==false)
                {
                    textView.setText("connected");
                }
                else
                {
                    textView.setText("Not connected");

                }
            }
        });
    }
    private static final String TAG = "Ftp Connection";


    public boolean ftpConnect( )
    {
        String host = "ftp.drivehq.com";
        String username ="hrharry20";
        String password ="**********";
        int port =21;

            try {
                FTPClient mFTPClient = new FTPClient();
                mFTPClient.connect(host, port);

                boolean status = mFTPClient.login(username, password);
                String oldFile = "//GroupWrite//Tally//dih.txt";
                String newFile = "//GroupWrite//Tally//dinesh.txt";

                boolean success = mFTPClient.rename(oldFile, newFile);
                if (success) {
                    Log.d("rename msg", oldFile + " was successfully renamed to: "
                            + newFile );


                } else {
                    Log.d("Failed to rename:", "dont"+oldFile );

                }

                mFTPClient.setFileType(FTP.BINARY_FILE_TYPE);
                mFTPClient.enterLocalPassiveMode();

                return true;//status;
            } catch(Exception e) {
                Log.d("connection msg", "Error: could not connect to host " + host );
            }
            return false;
        }
}

在主线程上执行internet代码时,将出现
NetworkOnMainThreadException
。查看日志。在主线程上执行internet代码时,将出现
NetworkOnMainThreadException
。看看航海日志。