Q:

How can I save a result set after running the Jmeter Test using a program (JAVA CODE)?

I have run the Jmeter Script using Jmeter dependency in eclipse using Java code, fortunately, my script is running fine but now I'm unable to store the result for the same. Can anyone please tell me how can I achieve this ?
please see the following code that I have tried. 
package com.solitera.automation.controller;

import org.apache.jmeter.engine.StandardJMeterEngine;
import org.apache.jmeter.save.SaveService;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.collections.HashTree;

import java.io.File;
import java.io.FileInputStream;

public class JMeterFromExistingJMX {

    public static void main(String[] argv) throws Exception {
        // JMeter Engine
        StandardJMeterEngine jmeter = new StandardJMeterEngine();

        // Initialize Properties, logging, locale, etc.
        JMeterUtils.loadJMeterProperties("D:/apache-jmeter-5.1.1/bin/jmeter.properties");
        JMeterUtils.setJMeterHome("D:/apache-jmeter-5.1.1");
        JMeterUtils.initLogging();// you can comment this line out to see extra log messages of i.e. DEBUG level
        JMeterUtils.initLocale();

        // Initialize JMeter SaveService
        SaveService.loadProperties();

        // Load existing .jmx Test Plan
       /* FileInputStream in = new FileInputStream("D:/Ecllipse_project_workspace2/slt_automation/src/test/jmeter/slt_autoMa_Test.jmx");
        HashTree testPlanTree = SaveService.loadTree(in);
        in.close();*/

        HashTree testPlanTree = SaveService.loadTree(new File("D:/apache-jmeter-5.1.1/extras/slt_auto_test_java_blaze_script.jmx"));

        // Run JMeter Test
        jmeter.configure(testPlanTree);
        jmeter.run();
    }

}

A:

I have solved it by myself..
if (summariserName.length() > 0) {  
    summer = new Summariser(summariserName);  
  }  

  String logFile = "D:/apache-jmeter-5.1.1/extras/resultss.xml";
  ResultCollector logger = new ResultCollector(summer);  
  logger.setFilename(logFile);
  testPlanTree.add(testPlanTree.getArray()[0], logger); 

