title: Properly check FTP server connection
body: <p>I open a connection to an FTP server at the start of my program.</p>
  
  <p>Before I perform operations on the server I want to check if the connection was successfully established. The easiest fast manner so if the connection is gone, I will try to connect again.</p>
  
  <p>I used this code to do this: </p>
  
  <pre><code>private boolean checkConnection()
  {
      try 
      {
          boolean success = ftpClient.login(user_name, password);
          if(success)
              return true;
          else 
              return false;
      }
  }
  </code></pre>
  
  <p>But this method throws a NullPointer exception when the connection was closed.</p>
  
  <p>I can check the connection with the <code>ftpClient.connect(server, port);</code> but that is like attampting to connect all over again.</p>
  
  <p>What is the bes way to check the connection?</p>