How to get the file extension in grails? -


i started working on grails , want know how extension of file. ex: test.txt. want check extension(txt)? clue?

here's way. using regular expression.

def filename = 'something.ext' def matcher = (filename =~ /.*\.(.*)$/)  if(matcher.matches()) {     def extension = matcher[0][1]      if(extension in ['jpg', 'jpeg', 'png']) {         // go         println 'ok'     } else {         println 'not ok'     } } else {     println 'no file extension found' } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -