• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

FTP Client Problem

 
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm writing a FTPClient application, but i keep getting this exception:
java.lang.NullPointerException
at sun.net.TransferProtocolClient.sendServer(TransferProtocolClient.java:99)
at sun.net.ftp.FtpClient.issueCommand(FtpClient.java:160)
at sun.net.ftp.FtpClient.openDataConnection(FtpClient.java:218)
at sun.net.ftp.FtpClient.get(FtpClient.java:315)
at archivetool.FTPClientDialog.getFile(FTPClientDialog.java:579)
at archivetool.FTPClientDialog.access$100(FTPClientDialog.java:22)
at archivetool.FTPClientDialog$3.run(FTPClientDialog.java:202)
the strange thing about this is that the application stops running at line 579, as can be seen above, which is in the middle of a method which performs the same get operation twice. The application performs the operation correctly the first time but not the second time.
Here's my code:

Please can someone help me with this
 
Author
Posts: 6055
8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't go through the code thoroughly, but I have two comments.
First, you're referencing an external object, client. It may make sense, but it also means something could be happening outside the method which is effecting it.
Second, consider using the Linlyn code, http://www.cs.uwplatt.edu/classes/se273/comm/ftpcomm.html If you use this, be warned, the basic code creates a byte array, and when the array gets filled, it creates a new one, twice the size, and copies thje contents from one to another. In this way, it's very inefficient. If you have any knowledge about the size of the data, you can make it much more efficent with only a few minutes of work.
--Mark
 
Peter Phung
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Unfortunately my work requires me to use only packages and classes released by sun.
I've posted all of the methods which use client below :

I've spent ages going over the code but i cant find the problem.
Please can someone help
Thanks
 
Peter Phung
Ranch Hand
Posts: 138
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any help would be apreciated
 
Space pants. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic