title: java ftp nullpointer exception
body: <p>I have code to upload a file to a server.</p>
  
  <pre><code>import org.apache.commons.net.ftp.FTPClient;
  
      import java.io.File;
      import java.io.IOException;
      import org.apache.commons.net.ftp.FTPFile;
      import java.io.FileInputStream;
      import java.net.SocketException;
  
      public class FtpConnectDemo {
          public static void main(String[] args) throws SocketException, IOException{
              FTPClient client = new FTPClient();
              FileInputStream fis = null;
  
              client.connect("ftp.someserver.co.uk",21);
              boolean login = client.login("webmaster@someserver.co.uk",
                      "mypassword");
  
  
              String filename = "E:/workbench j2ee/cPEP_UI/WebContent/engine.xml";
              client.storeFile(filename, fis);
              client.logout();
              fis.close();
          }
      }
  </code></pre>
  
  <p>and when I run this code, it is giving me this error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at FtpConnectDemo.main(FtpConnectDemo.java:22)
  </code></pre>
  
  <p>The username, password, servername are all right. What's wrong then?
  I am able to connect to FTP using telnet. 
  Any ideas?</p>
  
  <h3>EDIT 1</h3>
  
  <p>OK, now I am not getting the nullpointer exception, as I initialized <code>fis</code>. But my file is not uploaded yet; what might be the problem?</p>