Java 安卓 FTP 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1567601/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 14:10:38  来源:igfitidea点击:

Android FTP Library

javaandroidftp

提问by Darthg8r

I'm looking for a java library that works on the android that can download and resume files from an FTP server. Does anyone know of such a library. I've found lots of client apps, but no stand alone libraries.

我正在寻找一个可以在 android 上运行的 java 库,它可以从 FTP 服务器下载和恢复文件。有谁知道这样的图书馆。我发现了很多客户端应用程序,但没有独立的库。

采纳答案by jfarrell

Try using apache commons ftp

尝试使用apache commons ftp

FTPClient ftpClient = new FTPClient();
ftpClient.connect(InetAddress.getByName(server));
ftpClient.login(user, password);
ftpClient.changeWorkingDirectory(serverRoad);
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);

BufferedInputStream buffIn = null;
buffIn = new BufferedInputStream(new FileInputStream(file));
ftpClient.enterLocalPassiveMode();
ftpClient.storeFile("test.txt", buffIn);
buffIn.close();
ftpClient.logout();
ftpClient.disconnect();