title: How to use java program in bean pre-processor
body: <p>The below program reads the XML file and compress into gzip.</p>
  
  <p>I have a couple of questions here.</p>
  
  <ol>
  <li><p>Can I use the following program directly in JMeter BeanShell pre-processor?</p></li>
  <li><p>I want to use the output variable as input to JSON request. Is it possible in Jmeter?</p></li>
  <li><p>Screen shot and details will be appreciated.</p>
  
  <p>public static void main(String[] args) throws Exception {</p>
  
  <pre><code>String line = null; 
  String sb = "";
  File f=new File("D:\\RetailTransactionLog_9419_001_590.xml");
  FileReader fr=new FileReader(f);
  BufferedReader br=new BufferedReader(fr);   
  
  while((line=br.readLine())!=null)
  {
       sb= sb + line;
  }   
  br.close();
  
  
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  GZIPOutputStream gzos = new GZIPOutputStream(baos);
  gzos.write(sb.getBytes("UTF-8"));
  gzos.close();
  
  String base64CompressedString = Base64.getEncoder().encodeToString(baos.toByteArray());
  System.out.println(base64CompressedString);
  </code></pre></li>
  </ol>