title: ftp connection to determine if file is there
body: <p>I am trying to check if the file exist in the FTP. When testing with one user it seems to be fine. But with the scenario of multiple users it seems to throw the below exception :
  Exception in thread "main" sun.net.ftp.FtpProtocolException: Welcome message: 421.</p>
  
  <p>Below is the code which we use to check if file is there and we have closed all the connection but still it throws sun.net.ftp.FtpProtocolException:Welcome message: 421.</p>
  
  <pre><code> public boolean getFtpFileExists(String fileUrl)
    {
      URL theURL = null;
      InputStream inputStream = null;
      FtpURLConnection ftpUrlConn = null;
      boolean ftpFileExists = false;
  
      try
      {
        theURL = new URL(fileUrl);
        ftpUrlConn = (FtpURLConnection)theURL.openConnection();
        inputStream = ftpUrlConn.getInputStream();//calling this method will throw a 'FileNotFoundException' if doesn't exist
  
        ftpFileExists = true;
      }
      catch(FileNotFoundException fnfe)
      {
        ftpFileExists = false;
      }
      catch(Exception e)
      {
        System.out.println(e.toString());
        ftpFileExists = false;//hmm, not sure really!
      }
      finally
      {
        //close inputStream &amp; connection
        if(inputStream != null)
        {
          try
          {
            inputStream.close();
          }
          catch(IOException ioe)
          {
            System.out.println("Error closing input stream: "+ioe.getMessage());
          }
        }
  
        try
        {
          ftpUrlConn.close();
        }
        catch(Exception e)
        {
          System.out.println("Error closing ftpUrlConnection");
        }
      }
  
      return ftpFileExists;
    }
  </code></pre>
  
  <p>could anyone help me please?</p>