In Beanshell Post Processor I am creating a file and writing variable data received from a JDBC request to that file. I need to capture the file size of the created text file in KB and save to a variable so that I can call in a subsequent JDBC request.
Don't inline JMeter Functions or Variables inside scripts as they might resolve into something causing compilation failure or unexpected behavior or will be resolved only once.
You can save the size of the file into a JMeter Variable as:
vars.put("fileSize", String.valueOf(new File("/path/to/file").length().toString()));