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
Pete<br />"Reality is an illusion <br />brought on by a lack of <br />drink, drugs and smut"
Joined: Dec 04, 2000
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
Joined: Dec 06, 2001
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