This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
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.
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.