I am getting the following error when I use a BeanshellPostProcessor to regex some data and write to file:
2015/06/11 12:11:19 ERROR - jmeter.util.BeanShellInterpreter: Error invoking bsh method: eval Sourced file: inline evaluation of: `` import java.io.FileOutputStream; import java.util.Map; import java.u . . . '' Token Parsing Error: Lexical error at line 10, column 45. Encountered: "d" (100), after : "\"c:\\"
2015/06/11 12:11:19 WARN - jmeter.extractor.BeanShellPostProcessor: Problem in BeanShell script org.apache.jorphan.util.JMeterException: Error invoking bsh method: eval Sourced file: inline evaluation of: `` import java.io.FileOutputStream; import java.util.Map; import java.u . . . '' Token Parsing Error: Lexical error at line 10, column 45. Encountered: "d" (100), after : "\"c:\\"
My code:
import java.io.FileOutputStream;
import java.util.Map;
import java.util.Set;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.*;
String entirePage = new String(data);
FileWriter fstream = new FileWriter("c:\\downloads\\results.txt",true);
BufferedWriter out = new BufferedWriter(fstream);
Pattern totalNetValue = Pattern.compile("totalNetValue\">([^\"]+)</span>");
Matcher mTotalNetValue = totalNetValue.matcher(entirePage);
mTotalNetValue.find();
//out.write(${date});
out.write(mTotalNetValue.group(1));
out.write("\n");
out.close();
Any ideas what's wrong with my code? Thanks :-)
How do you read the code into the bsh interpreter? It sure looks like the double backslashes are reduced to single ones.
As a quick fix, just use forward slashes instead of backslashes, e.g.