Forum Discussion
Lucian
7 years agoCommunity Hero
Trailing spaces often mean trouble. I would suggest to implement a regex to manipulate the folderPath in the first place. For instance:
// Get the folder path folderPath = 'c:/testfileGroovy /' // Clean the folder path folderPath = folderPath.replaceAll(" /", "/")
Cheers!
- PramodYadav7 years agoContributor
Good idea !
To make it even more foolproof (for more than one spaces), we can use:
// Make a folder
folderPath = 'c:/testfileGroovy/'
log.info "folderPath with spaces : $folderPath"
// clean the fodler path
folderPath = 'c:/testfileGroovy /'
folderPath = folderPath.replaceAll(~/ / ,'')
log.info "folderPath cleared from spaces : $folderPath"P.S: Ofcourse the condition is we don't use spaces in folder names (which is actually not a good practice if you have anything to run on command line).
Related Content
- 4 years ago
- 10 years ago
Recent Discussions
- 11 days ago