Home How to check file Exist or not?
Reply: 0

How to check file Exist or not?

user8839
1#
user8839 Published in September 19, 2018, 11:02 am

This question already has an answer here:

  • Checking file existence on FTP server 2 answers

Here I'm trying to check whether the file exist or not.but the below code doesn't return anything and also get the error at this line

Error line : Boolean t = fileslist.Exists()

   start()
    def start(){
    def store;
    boolean success;
    def ftpClient = new FTPClient()
    ftpClient.connect(server)
    ftpClient.login(user,pass) 
     ftpClient.enterLocalPassiveMode()
     FTPFile[] fileslist = ftpClient.listFiles("/Sample.txt")
     ftpClient.setFileType(FTP.BINARY_FILE_TYPE)
     filelist.each{
          it.exists()
       }  
     ftpClient.disconnect() 

    }

Thanks

share|improve this question

marked as duplicate by Martin Prikryl ftp StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var $hover = $(this).addClass('hover-bound'), $msg = $hover.siblings('.dupe-hammer-message'); $hover.hover( function() { $hover.showInfoMessage('', { messageElement: $msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Apr 17 at 11:56

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Your code snippet doesn't show what you want to do with the file if it exists... What are you trying to do? Also, why are you listing files using a file name path? – ernest_k Apr 17 at 11:28
  • I'm just checking whether the file exist in ftp or not – chanbasha sk Apr 17 at 11:34
  • I have posted a more verbose answer to an existing question. – Martin Prikryl Apr 17 at 11:57

1 Answer 1

active oldest votes
up vote 0 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.705483 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO