title: Android: How can I get the file size of a FTP file via FTPClient?
body: <p>How can I read the file size of a file that is stored on my ftp server?
  I don't like to implement another libary.</p>
  
  <p>I am working with commons-io-2.4 and commons-net-3.1</p>
  
  <p><strong>Answer and code from talhakosen (thanks!)</strong></p>
  
  <pre><code>private long getFileSize(FTPClient ftp, String filePath) throws Exception {
      long fileSize = 0;
      FTPFile[] files = ftp.listFiles(filePath);
      if (files.length == 1 &amp;&amp; files[0].isFile()) {
          fileSize = files[0].getSize();
      }
      Log.i(TAG, "File size = " + fileSize);
      return fileSize;
  }
  </code></pre>