Below are my code for the checkDTS function. I have to store the status of the DTS in the separated text file in 10 minutes interval.
private boolean DTS_firstTime = true;
private int num_of_DTS_tries = 0;
private long interval_DTS = 5 * 60 * 1000;
public void checkDTS(){
//  log.info("===Check DTS===");
    if((System.currentTimeMillis() - remoteLane.getLastDTSReceived() > interval_DTS)){
        if(num_of_DTS_tries >= 5){
            //if (ipc_reachable) {
            if (getStates().getLNK().isStatus()) {
                if (getStates().getDTS().isStatus() || DTS_firstTime) {
                    log.info(getRemoteLane().getName() + ">>DTS Service Failed.");
                    DTS_firstTime = false;
                    getStates().getDTS().setStatus(false);
                    getRemoteLane().setDTSMode("");
                    dataSyncStopPlayback = false;
                    doDataSyncAlert();
                    doDataSyncDisplay();
                }
            }
            remoteLane.setLastDTSReceived(System.currentTimeMillis());
            num_of_DTS_tries = 0;
        } else {
            sendDTSCommand(Status.ISDTSUP, "");
        }
        num_of_DTS_tries++;
    } else{
//      log.debug("DTS Mode: " +getRemoteLane().getDTSMode());
        if (getRemoteLane().getDTSMode().equalsIgnoreCase(Status.OK)){
            //if (ipc_reachable) {
            if (getStates().getLNK().isStatus()) {
            //  if (!getStates().getDTS().isStatus()) {
            //      clrDataSyncDisplay();
            //  }
                getStates().getDTS().setStatus(true);
                dataSyncStopPlayback = true;
                dataSyncAlert = false;
                if (!alert && !discrepancyalert && !exitWarningAlert) {
                    getLane().setRoadBackground(getLane().stateColor);
                }
                //clrDataSyncDisplay();
            }
        } else if (getRemoteLane().getDTSMode().equalsIgnoreCase(Status.NG)){
            //if (ipc_reachable) {
            if (getStates().getLNK().isStatus()) {
                if (getStates().getDTS().isStatus() || DTS_firstTime) {
                    log.info(getRemoteLane().getName() + ">>DTS Service Failed..");
                    DTS_firstTime = false;
                    getStates().getDTS().setStatus(false);
                    dataSyncStopPlayback = false;
                    doDataSyncAlert();
                    doDataSyncDisplay();
                    try{
                        PrintStream myconsole = new PrintStream (new File ("E://TMC//250216.y.txt"));
                        System.setOut(myconsole);
                        myconsole.print();
                    } catch (FileNotFoundException fx) {
                        System.out.println(fx);
                    }
                }
            }
        }
    //  getStates().getDTS().setStatus(true);
        num_of_DTS_tries = 0;
    }   
    this.repaint();
}
I try to put this segment of code for the storing DTS status into the file.But then, I don't know which line should i put in myconsole.print() since I am not that familiar with this code.
try{
    PrintStream myconsole = new PrintStream(new File("E://TMC//250216.y.txt"));
    System.setOut(myconsole);
    myconsole.print();
    } catch (FileNotFoundException fx) {
      System.out.println(fx);
    }
The existing example only show on how to create new file and store in it. But mine, i know how to create file. But, i don't know how to fetch the DTS status from code (which line should i execute?) and save it in text file.
 
     
    