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!
PramodYadav
7 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
- 5 years ago
Recent Discussions
- 3 days ago
- 5 days ago