如何使用 beanshell 从路径中提取文件名
How to extract filename from path using beanshell
获取错误消息为空
如何使用 beanshell 从路径中提取文件名
假设文件路径 = /home/user/desktop/file.txt
我想在 jmeter
中使用 beanshell 单独获取 file.txt
您可以像这样使用 FilenameUtils.getPath() method:
import org.apache.commons.io.FilenameUtils;
filepath = "/home/user/desktop/file.txt";
filename = FilenameUtils.getName(filepath);
log.info(filename);
演示:
请注意,建议使用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了解更多详情。
获取错误消息为空 如何使用 beanshell 从路径中提取文件名 假设文件路径 = /home/user/desktop/file.txt 我想在 jmeter
中使用 beanshell 单独获取 file.txt您可以像这样使用 FilenameUtils.getPath() method:
import org.apache.commons.io.FilenameUtils;
filepath = "/home/user/desktop/file.txt";
filename = FilenameUtils.getName(filepath);
log.info(filename);
演示:
请注意,建议使用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了解更多详情。