1

Trying to get the files from filepath using java.io.File "File f = new File("//DEV/Test")" in beanshellsampler JMeter configured in Jenkins, when try to get the absolute path, getting only "/Dev/Test". one '/' is missing.

String folderPath = "//Dev/Test";

#oneway
File folder = new File(folderPath);
folder.toAbsolutePath(); //output :: /Dev/Test

#Secondway
Path p1 = Paths.get(foldertoString, new String[0]);
File pathtoFile = p1.toFile(); 
String[] fn = pathtoFile.list();
// output : path is not correct
Kiran
  • 167
  • 2
  • 15

1 Answers1

0

It's not missing, / is the root of the Linux file system, there is no need to have an extra slash there.

Also be informed that starting from JMeter 3.1 it's recommended to use JSR223 Test Elements and Groovy language for scripting so consider migrating on next available opportunity.

More information on Groovy scripting in JMeter: Apache Groovy: What Is Groovy Used For?

Dmitri T
  • 159,985
  • 5
  • 83
  • 133