• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Slow Swing FTP Problem

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys,

I'm trying to create a swing gui to ftp a file onto a server. I'm using the apache commons package to achieve this. I'm using the following code;



Standalone it works fine, no problems. However when I try to run it through a swing gui it just seems to slow right down. I've tried to call the above code in several different ways. For example, by calling it directly from an actionListener attached to a button, and then by placing this in the doInBackround() method of a swing worker thread, then calling the class's execute method. Wherever I call it, there is still this slowdown in execution. Using the sys outs above I see there is a huge pause between the "store file" and "file stored. Logout" outputs. Then I thought it could be a memory issue, so I decided to increase the JVM heap using Xms and Xms runtime parameters. But still no difference!

I cant work out why it takes so long to ftp from a swing gui when the same piece of code standalone works perfectly fine. Does anyone have any suggestions or clues as to why this is happening? I'm not a swing expert, so I'm at a loss.

Any help would be greatly appreciated.

Thanks
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing obvious jumps out at me. What happens if you replace
  • new FileInputStream(sourceFile.getAbsolutePath())
  • with
  • new BufferedInputStream(new FileInputStream(sourceFile.getAbsolutePath()))
  • Does it help any?

    Also, this is probably unrelated to your performance problem, but does the storeFile() method close the stream? If not, you should close it yourself.
     
    Jaz Chana
    Ranch Hand
    Posts: 34
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Brian Cole wrote:Nothing obvious jumps out at me. What happens if you replace

  • new FileInputStream(sourceFile.getAbsolutePath())
  • with
  • new BufferedInputStream(new FileInputStream(sourceFile.getAbsolutePath()))
  • Does it help any?

    Also, this is probably unrelated to your performance problem, but does the storeFile() method close the stream? If not, you should close it yourself.



    I've just had a very weird result. I tried to uplod to the FTP server from an external network via a vpn connection and suddenly its a hell of alot faster, in both cases!! I would have said this isn't a swing related problem, if it wasn't for the fact that the standalone app works perfectly fine in both inside and outside the network. Only the swing app slows down the upload inside the network. I will try the your suggestions when I get back on the network. Thanks for the heads up on the FileInputStream.
     
    The harder you work, the luckier you get. This tiny ad brings luck - just not good luck or bad luck.
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic