apache-commons-net

Download entire FTP directory in Java (Apache Net Commons)

安稳与你 提交于 2019-12-30 11:12:20
问题 I am trying to recursively iterate through the entire root directory that I arrive at after login to the FTP server. I am able to connect, all I really want to do from there is recurse through the entire structure and and download each file and folder and have it in the same structure as it is on the FTP. What I have so far is a working download method, it goes to the server and gets my entire structure of files, which is brilliant, except it fails on the first attempt, then works the second

Apache Commons NET: Should I create a new FTPClient object on each connection or reuse one?

不想你离开。 提交于 2019-12-30 08:24:06
问题 I'm just wondering: in my Java application, each time I need to connect to an FTP server, should I create a new FTPClient object, or should I create one FTPClient() object and re-use that each time I connect to an FTP server? 回答1: Reusing would be better since you wont need a new instance every time you are creating a new connection, even to a new server. Because the connect and disconnect methods can do the job for you. So reuse as many objects as you can. 回答2: Both will work, but apache

FtpClient storeFile always return False

南楼画角 提交于 2019-12-28 05:51:10
问题 Please figure this out. The code runs properly without any exception. FTPClient ftp = new FTPClient(); ftp.connect(server); if(!ftp.login(username, password)) { ftp.logout(); return false; } int reply = ftp.getReplyCode(); if (!FTPReply.isPositiveCompletion(reply)) { ftp.disconnect(); return false; } InputStream in = new FileInputStream(localfile); ftp.setFileType(ftp.BINARY_FILE_TYPE, ftp.BINARY_FILE_TYPE); ftp.setFileTransferMode(ftp.BINARY_FILE_TYPE); Store = ftp.storeFile(destinationfile,

FTP connection through proxy with Java

大城市里の小女人 提交于 2019-12-22 12:57:21
问题 I'm trying to connect to an FTP server through a proxy using org.apache.commons.net.ftp.FTPClient. Pretty sure the system properties are getting set correctly as per following: Properties props = System.getProperties(); props.put("ftp.proxySet", "true"); // dummy details props.put("ftp.proxyHost", "proxy.example.server"); props.put("ftp.proxyPort", "8080"); Creating a connection raises a UnknownHostException which I'm pretty sure means the connection isn't making it past the proxy. How can

FTP file corrupt after download with Apache Commons Net

做~自己de王妃 提交于 2019-12-22 10:37:52
问题 The files downloaded by this, are nearly the same size but differ in some lines. Every answer points to binary file type. But this won't help. Got anybody an idea for the problem (transferring PDF)? FTPClient ftpClient = new FTPClient(); OutputStream outputStream = null; boolean resultOk = true; try { ftpClient.connect(host, port); ftpClient.enterLocalPassiveMode(); ftpClient.setFileTransferMode(FTP.COMPRESSED_TRANSFER_MODE); ftpClient.setFileType(FTP.BINARY_FILE_TYPE); if (showMessages) {

Filename encoding in Apache Commons Net FTPClient

六月ゝ 毕业季﹏ 提交于 2019-12-21 03:39:07
问题 I have to upload a file to an FTP server. The filename contains special letters, say äöü . On the FTP server, I need the filename to be UTF-8 encoded. My code is like this: import org.apache.commons.net.ftp.FTPClient; FTPClient client = new FTPClient(); ... boolean retval = client.storeFile(fileName, inputStream); The problem is that after storeFile , the name of the file saved on the FTP server is ISO-8859-1 encoded rather than UTF-8. How can I tell FTPClient to UTF-8 encode the file names?

FTPClient Uploading File = SocketException: Connection reset

此生再无相见时 提交于 2019-12-20 20:23:42
问题 I'm trying to upload a simple txt file via FTP using XAMPP and FileZilla. I'm using the Apache Commons Net 3.0.1 Library. This is my code, very basic things: FTPClient client = new FTPClient(); InputStream in = new ByteArrayInputStream("IT WORKS! :D".getBytes()); try { client.connect("localhost"); client.login("user", "password"); client.enterLocalPassiveMode(); client.storeFile("textfile.txt", in); } finally { try { in.close(); client.logout(); client.disconnect(); } catch (Exception e) { }

android ftp file tranfer over explicit TLS

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 15:26:04
问题 I'm posting this question after have tried over and over again to get it working, with no success. I trying to implement a FTP file transfer in android, using apache commons library. The communication must be done through explicit TLS authentication. I can successfully login, connect to the server and list files, but whenever i try to get or store a file, I always get a timeout exception, also with very large timeout value, even for a 2Kb txt file. This is my code: FTPSClient ftpClient = new

android ftp file tranfer over explicit TLS

最后都变了- 提交于 2019-12-20 15:25:22
问题 I'm posting this question after have tried over and over again to get it working, with no success. I trying to implement a FTP file transfer in android, using apache commons library. The communication must be done through explicit TLS authentication. I can successfully login, connect to the server and list files, but whenever i try to get or store a file, I always get a timeout exception, also with very large timeout value, even for a 2Kb txt file. This is my code: FTPSClient ftpClient = new

Upload file via Ant FTP task in Maven

筅森魡賤 提交于 2019-12-19 07:28:12
问题 I'm trying to upload a file using an Ant task. If I use Ant directly the file is uploaded, but if I call the ant task via Maven (using the maven-antrun-plugin ) I get the following error: An Ant BuildException has occured: The following error occurred while executing this line: /home/me/proj/build.xml:15: Problem: failed to create task or type ftp Cause: the class org.apache.tools.ant.taskdefs.optional.net.FTP was not found. This looks like one of Ant's optional components. Action: Check that