Getting error message empty How to extract filename from path using beanshell Suppose filepath = /home/user/desktop/file.txt I want to get file.txt seperately using beanshell in jmeter
1 Answers
0
votes
You could use FilenameUtils.getPath() method like:
import org.apache.commons.io.FilenameUtils;
filepath = "/home/user/desktop/file.txt";
filename = FilenameUtils.getName(filepath);
log.info(filename);
Demo:
Be aware that it is recommended to use JSR223 Elements and Groovy language instead of Beanshell, Groovy has better performance, it's more Java-compatible and it has some extra language features, see Apache Groovy - Why and How You Should Use It for more details.