Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 41497 invoked from network); 19 Apr 2008 13:55:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Apr 2008 13:55:59 -0000 Received: (qmail 23284 invoked by uid 500); 19 Apr 2008 13:55:57 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 23233 invoked by uid 500); 19 Apr 2008 13:55:57 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 23224 invoked by uid 99); 19 Apr 2008 13:55:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 19 Apr 2008 06:55:57 -0700 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [98.136.44.41] (HELO n69.bullet.mail.sp1.yahoo.com) (98.136.44.41) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 19 Apr 2008 13:55:04 +0000 Received: from [216.252.122.217] by n69.bullet.mail.sp1.yahoo.com with NNFMP; 19 Apr 2008 13:55:20 -0000 Received: from [69.147.84.88] by t2.bullet.sp1.yahoo.com with NNFMP; 19 Apr 2008 13:55:20 -0000 Received: from [127.0.0.1] by omp204.mail.sp1.yahoo.com with NNFMP; 19 Apr 2008 13:55:20 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 949132.79995.bm@omp204.mail.sp1.yahoo.com Received: (qmail 37567 invoked by uid 60001); 19 Apr 2008 13:55:20 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=FiLfvV79EzEBlE5gs06MY5s4LCY43aYTeV7hMRRA3+B6VcEq+/p2WkO0JYmPwLGokfbqGhh1Gn6Lp8qn4RkPTyHfQfkxAy+JCyUIQ7EqYIOjtjsToUrMM28L5V+XcPxpj74EMQA+/E6qAVjia/6NI9tbJwLQ8QcI464L8DlEyf0=; X-YMail-OSG: INz4HEMVM1mShgQfbDcForRY9_ZepcCQl8LrDYNIQYlb._m.D.hjt20ppF1sYhskyIRlT0sYeDmAkL8TdU8oF9VNc6UvxjwD.g-- Received: from [77.105.19.151] by web45616.mail.sp1.yahoo.com via HTTP; Sat, 19 Apr 2008 06:55:20 PDT Date: Sat, 19 Apr 2008 06:55:20 -0700 (PDT) From: Zoran Jeremic Subject: Re: problem to create FTP client To: Jakarta Commons Users List In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1314289349-1208613320=:36060" Content-Transfer-Encoding: 8bit Message-ID: <684781.36060.qm@web45616.mail.sp1.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org --0-1314289349-1208613320=:36060 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit James, Thank you again. Actually that was the real problem. I missed to close stream. It works now even with bufferSize=10. Do you have any suggestion about this buffer size? Is it better to put a a higher value in order to prevent performance issue? Regards Zoran James Carman wrote: Did you also make sure you're closing the stream after you copy it? Sometimes, the streams don't actually write the last bit of data unless they're flushed (happens when you close it). So try: copy(fis, os); os.flush(); os.close(); The reason that I don't close the output stream in the copy() method is that you might want to copy the contents of more than one stream to the output stream (concatenating files perhaps?). On Sat, Apr 19, 2008 at 8:45 AM, Zoran Jeremic wrote: > Hi James, > > Thank you for your help. It works in this way you suggested me but if I set the bufferSize on 10000. If I set it for example to 1000 I get black box instead of the class on class diagram picture. I have tried it with very simple project and simple UML diagram. > > Can you please explain me is there something like optimal buffersize for network trafic? I'm not sure how big the project and picture uploaded this way could be, as it depends on user, and maybe it can be very big. > > Regards > Zoran > > > James Carman wrote: > Have you tried closing the output stream? Also, you might want to try > copying more than one byte at a time. I usually use a byte[] buffer: > > public static void copy(InputStream in, OutputStream out, int > bufferSize) throws IOException > { > int bytesRead = -1; > final byte[] buffer = new byte[bufferSize]; > while ((bytesRead = in.read(buffer)) != -1) > { > out.write(buffer, 0, bytesRead); > } > } > > Hope that helps! > > > > On Sat, Apr 19, 2008 at 8:05 AM, Zoran Jeremic wrote: > > Hi, > > > > I'm using a commons-net to upload an ArgoUML project (archive with extension .zargo) and its class diagram as picture (.png) to the remote FTP server. Its works fine in case FTP client and FTP server are on the same PC. However, if the FTP client is on other PC it also upload both files picture and project to the FTP repository but those files has only 1 kb instead of 5 or more and are unreadable. > > Here is the code: > > > > public void createConnectionToFTPServer(String host,String username, String password){ > > > > try{ > > ftp.connect(host); > > ftp.login(username, password); > > int reply=ftp.getReplyCode(); > > if(FTPReply.isPositiveCompletion(reply)){ > > LOG.info("Connected Successfully to the FTP server"); > > }else{ > > LOG.info("Connection to the FTP server Failed"); > > ftp.disconnect(); > > } > > ... > > public void uploadFileToRepository(File file,String filename){ > > try{ > > ftp.setFileType(FTP.IMAGE_FILE_TYPE); > > LOG.info("uploadFileToRepository"); > > InputStream fis = new FileInputStream(file); > > OutputStream os = ftp.storeFileStream(filename); > > int t=0; > > while( (t=fis.read()) >=0){ > > os.write(t); > > } > > }catch(IOException ioe){ > > ... > > > > public void closeConnection(){ > > try{ > > ftp.disconnect(); > > .... > > I hope that somebody has an idea what can be problem. > > > > Thanks > > Zoran > > > > > > > > --------------------------------- > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@commons.apache.org > For additional commands, e-mail: user-help@commons.apache.org > > > > > > > --------------------------------- > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@commons.apache.org For additional commands, e-mail: user-help@commons.apache.org --------------------------------- Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. --0-1314289349-1208613320=:36060--