I would set it to something that's more likely to be a block size. Try 1024 or 2048 or something.
On 4/19/08, Zoran Jeremic <[EMAIL PROTECTED]> wrote: > 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > --------------------------------- > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > --------------------------------- > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. -- Sent from my mobile device --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]