Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 10266 invoked from network); 21 Dec 2004 06:47:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 21 Dec 2004 06:47:56 -0000 Received: (qmail 49639 invoked by uid 500); 21 Dec 2004 06:47:41 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 49626 invoked by uid 500); 21 Dec 2004 06:47:41 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 49609 invoked by uid 99); 21 Dec 2004 06:47:41 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from 218.141.125.209.transedge.com (HELO titan.idc-global.com) (209.125.141.218) by apache.org (qpsmtpd/0.28) with ESMTP; Mon, 20 Dec 2004 22:47:37 -0800 Received: from TWERGES (TWERGES.idc.local [192.168.0.60]) by titan.idc-global.com (Postfix) with ESMTP id 66CCC1BBB4 for ; Mon, 20 Dec 2004 22:47:36 -0800 (PST) From: "Tom Werges" To: Subject: [net] FTPClient.retrieveFileStream returns null even when no error is encountered Date: Mon, 20 Dec 2004 22:45:15 -0800 MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Office Outlook, Build 11.0.5510 Thread-Index: AcTnKKC7UuoRGd5FS7+B/ui8A6JYSg== X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-Id: <20041221064736.66CCC1BBB4@titan.idc-global.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N The FTPClient.retrieveFileStream method is returning null on all invocations after the first one on the same connection. The javadoc indicates that a null will only be returned in case of an error, in which case I can check the reply code for the exact problem. But the reply code indicates that everything went fine with no errors, and a null is still returned. The retrieveFile method works properly even if I call it repeatedly. However the retrieveFile method is not suitable for my purposes because I require an InputStream for updating a gui. I haven't entered this into the bug database yet because I'm assuming I'm making an elementary mistake. However I was not able to find any information on this issue in the mailing list archives or in the FAQ. The code is as follows: InputStream is = null; OutputStream os = null; for (TransferItem item : xferItems) { try { os = new FileOutputStream(new File(item.getLocalPath())); //local destination // retrieveFile method WORKS PROPERLY: // // ftpClient.retrieveFile(item.getServerPath(), os); // however, retrieveFileStream (following) does not work properly: is = ftpClient.retrieveFileStream(item.getServerPath()); System.out.printf("Retrieve file [%s], code:%s, reply:%s", item.getServerPath(), ftpClient.getReplyCode(), ftpClient.getReplyString()); if (is == null) { System.out.println("InputStream was null! Skipping..."); continue; } copyStream(is, os); } finally { if (is != null) is.close(); if (os != null) os.close(); } } The initial invocation works fine, after which I always get a null plus a message that everything is fine. One possibly relevant detail is that the reply codes are not always the same. The first invocation has a reply code of 150 ("Opening BINARY mode data connection"), whereas the second has 200 ("PORT command successful. Consider using PASV."). Subsequent invocations yield 150 once again. I'm using jdk1.5 on linux connecting to a vsftp server on linux. Thanks for any help, Tom W --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org