Example usage for java.io BufferedWriter newLine

List of usage examples for java.io BufferedWriter newLine

Introduction

In this page you can find the example usage for java.io BufferedWriter newLine.

Prototype

public void newLine() throws IOException 

Source Link

Document

Writes a line separator.

Usage

From source file:Evaluator.PerQueryRelDocs.java

public void storeRunQid(String fileName) throws IOException, Exception {

    FileReader fr = new FileReader(new File(runFileList));
    BufferedReader br = new BufferedReader(fr);
    String line = br.readLine();/*from   w ww  . j av a  2s .c  om*/
    ArrayList<String> runlist = new ArrayList<>();
    while (line != null) {
        runlist.add(line);
        line = br.readLine();
    }
    br.close();
    HashMap<String, HashMap<Integer, Double>> runQidApMap = new HashMap<>();
    HashMap<String, Double> qidCosineMap = new HashMap<>();
    for (int pos = startQid; pos <= endQid; pos++) {
        Integer qidValue = pos;
        InferredApKDE iapk = new InferredApKDE(qidValue.toString(), 5, "", this, reader, .30, h, sigma,
                cosineFolderPath, lambda, relRcds.perQueryRels.get(qidValue.toString()).searcher);
        System.out.println(pos);
        qidCosineMap = iapk.reldocList.perQuerydocCosineSim;
        HashMap<String, Double> docRankMap = null;
        if (kdeMode.equals("2")) {
            docRankMap = computeAvgRank(runlist, pos, iapk.sampledData);
        }

        for (int j = 0; j < runlist.size(); j++) {
            retRcds.resFile = runFileFolderPath + "/" + runlist.get(j);
            retRcds.allRetMap = new TreeMap<>();
            retRcds.load();
            Set<String> rel = new HashSet<String>();
            Iterator it = iapk.sampledData.iterator();
            HashMap<String, Integer> rankMap = new HashMap<>();
            while (it.hasNext()) {
                String st = (String) it.next();
                if (iapk.reldoc.contains(st)) {
                    rel.add(st);
                }
            }

            iapk.retriveList = this.retRcds.allRetMap.get(qidValue.toString());
            iapk.processRetrievedResult();

            iapk.computeprob(iapk.retriveList.pool);
            double g = iapk.evaluateAP();
            //  System.out.println("kk" + g);
            HashMap<Integer, Double> qidApMap = runQidApMap.get(runlist.get(j));
            if (qidApMap == null) {
                qidApMap = new HashMap<>();
            }
            qidApMap.put(qidValue, g);
            runQidApMap.put(runlist.get(j), qidApMap);
        }

    }
    FileWriter fw = new FileWriter(new File(fileName));
    BufferedWriter bw = new BufferedWriter(fw);
    for (int j = 0; j < runlist.size(); j++) {
        HashMap<Integer, Double> values = runQidApMap.get(runlist.get(j));
        double sum = 0;
        for (int i = startQid; i <= endQid; i++) {
            sum += values.get(i);
        }
        bw.write(runlist.get(j) + " " + sum / (endQid - startQid + 1));
        bw.newLine();
        // System.out.println(sum / (endQid - startQid + 1));
    }
    bw.close();
}

From source file:chibi.gemmaanalysis.OutlierDetectionTestCli.java

/*** Write results to the output file; file name must be given as argument ***/
private void writeResultsToFileByMedian(BufferedWriter bw, ExpressionExperiment ee,
        OutlierDetectionTestDetails testDetails) {
    NumberFormat nf = NumberFormat.getInstance();
    nf.setMaximumFractionDigits(4);//from  w  w  w . ja  v a  2  s  .co m
    try {
        // Get information about the experiment:
        ee = this.eeService.thawLite(ee);
        System.out.println("Writing results to file for " + ee.getShortName());
        bw.write(ee.getShortName());
        bw.write("\t" + getPlatforms(ee));
        bw.write("\t" + testDetails.getNumExpFactors());
        if (useRegression) {
            bw.write("\t" + testDetails.getNumSigFactors());
        }
        bw.write("\t" + ee.getBioAssays().size());
        bw.write("\t" + testDetails.getNumOutliers());
        // Get information about each of the outliers (should be in sorted order since outliers is a sorted list):
        for (OutlierDetails outlier : testDetails.getOutliers()) {
            bw.write("\t" + outlier.getBioAssay().getName());
            bw.write("\t" + nf.format(outlier.getFirstQuartile()) + "/"
                    + nf.format(outlier.getMedianCorrelation()) + "/" + nf.format(outlier.getThirdQuartile()));
        }
        if (useRegression) {
            for (ExperimentalFactor factor : testDetails.getSignificantFactors()) {
                bw.write("\t" + factor.getName());
            }
        }
        bw.newLine();

    } catch (IOException e) {
        throw new RuntimeException(e);
    }

}

From source file:org.openmrs.module.clinicalsummary.web.controller.utils.ExtendedDataEncounterController.java

@RequestMapping(method = RequestMethod.POST)
public void processSubmit(final @RequestParam(required = true, value = "data") MultipartFile data,
        final @RequestParam(required = true, value = "conceptNames") String conceptNames,
        final HttpServletResponse response) throws IOException {

    List<Concept> concepts = new ArrayList<Concept>();
    for (String conceptName : StringUtils.splitPreserveAllTokens(conceptNames, ",")) {
        Concept concept = Context.getConceptService().getConcept(conceptName);
        if (concept != null)
            concepts.add(concept);//from  w  w  w. j  a v  a  2s  . co  m
    }

    PatientService patientService = Context.getPatientService();
    PatientSetService patientSetService = Context.getPatientSetService();

    File identifierData = File.createTempFile(STUDY_DATA, INPUT_PREFIX);
    OutputStream identifierDataStream = new BufferedOutputStream(new FileOutputStream(identifierData));
    FileCopyUtils.copy(data.getInputStream(), identifierDataStream);

    File extendedData = File.createTempFile(STUDY_DATA, OUTPUT_PREFIX);
    BufferedWriter writer = new BufferedWriter(new FileWriter(extendedData));

    String line;
    BufferedReader reader = new BufferedReader(new FileReader(identifierData));
    while ((line = reader.readLine()) != null) {
        Patient patient = null;

        String[] elements = StringUtils.splitPreserveAllTokens(line, ",");
        try {
            if (isDigit(StringUtils.trim(elements[1])))
                patient = patientService.getPatient(NumberUtils.toInt(elements[1]));
            else {
                Cohort cohort = patientSetService.convertPatientIdentifier(Arrays.asList(elements[1]));
                for (Integer patientId : cohort.getMemberIds()) {
                    Patient cohortPatient = patientService.getPatient(patientId);
                    if (cohortPatient != null && !cohortPatient.isVoided())
                        patient = cohortPatient;
                }
            }
        } catch (Exception e) {
            log.error("Unable to resolve patients!", e);
        }

        Date referenceDate = WebUtils.parse(elements[2], "MM/dd/yyyy", new Date());

        if (patient != null) {
            ExtendedData extended = new ExtendedData(patient, referenceDate);
            extended.setEncounters(searchEncounters(patient));
            for (Concept concept : concepts)
                extended.addObservations(concept, searchObservations(patient, concept));
            writer.write(extended.generateEncounterData());
            writer.newLine();

            ResultCacheInstance.getInstance().clearCache(patient);
        } else {
            writer.write("Unresolved patient id or patient identifier for " + elements[1]);
            writer.newLine();
        }
    }

    reader.close();
    writer.close();

    InputStream inputStream = new BufferedInputStream(new FileInputStream(extendedData));

    response.setHeader("Content-Disposition", "attachment; filename=generated-" + data.getOriginalFilename());
    response.setContentType("text/plain");
    FileCopyUtils.copy(inputStream, response.getOutputStream());
}

From source file:de.bfs.radon.omsimulation.gui.OMPanelTesting.java

/**
 * Initialises the interface of the results panel.
 *//*from ww  w. j a  v  a  2 s .c o  m*/
protected void initialize() {

    setLayout(null);
    isSimulated = false;

    lblExportChartTo = new JLabel("Export chart to ...");
    lblExportChartTo.setBounds(436, 479, 144, 14);
    lblExportChartTo.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    lblExportChartTo.setVisible(false);
    add(lblExportChartTo);

    btnCsv = new JButton("CSV");
    btnCsv.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.csv", "csv"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String csv;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("csv")) {
                    csv = "";
                } else {
                    csv = ".csv";
                }
                String csvPath = file.getAbsolutePath() + csv;
                double[] selectedValues;
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                final int day = 24;
                File csvFile = new File(csvPath);
                try {
                    OMCampaign campaign;
                    if (isResult) {
                        campaign = getResultCampaign();
                    } else {
                        campaign = new OMCampaign(start, rooms, 0);
                    }
                    FileWriter logWriter = new FileWriter(csvFile);
                    BufferedWriter csvOutput = new BufferedWriter(logWriter);
                    csvOutput.write("\"ID\";\"Room\";\"Radon\"");
                    csvOutput.newLine();
                    selectedValues = campaign.getValueChain();
                    int x = 0;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[0].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[1].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[2].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[3].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[4].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[5].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    start = start + day;
                    for (int i = start; i < start + day; i++) {
                        csvOutput.write("\"" + i + "\";\"" + rooms[6].getId() + "\";\""
                                + (int) selectedValues[x] + "\"");
                        csvOutput.newLine();
                        x++;
                    }
                    JOptionPane.showMessageDialog(null, "CSV saved successfully!\n" + csvPath, "Success",
                            JOptionPane.INFORMATION_MESSAGE);
                    csvOutput.close();
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null,
                            "Failed to write CSV. Please check permissions!\n" + ioe.getMessage(), "Failed",
                            JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write CSV. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnCsv.setBounds(590, 475, 70, 23);
    btnCsv.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnCsv.setVisible(false);
    add(btnCsv);

    btnPdf = new JButton("PDF");
    btnPdf.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.pdf", "pdf"));
            fileDialog.showSaveDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String pdf;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("pdf")) {
                    pdf = "";
                } else {
                    pdf = ".pdf";
                }
                String pdfPath = file.getAbsolutePath() + pdf;
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                OMCampaign campaign;
                try {
                    if (isResult) {
                        campaign = getResultCampaign();
                    } else {
                        campaign = new OMCampaign(start, rooms, 0);
                    }
                    JFreeChart chart = OMCharts.createCampaignChart(campaign, false);
                    String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId()
                            + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId()
                            + ", Start: " + start;
                    int height = (int) PageSize.A4.getWidth();
                    int width = (int) PageSize.A4.getHeight();
                    try {
                        OMExports.exportPdf(pdfPath, chart, width, height, new DefaultFontMapper(), title);
                        JOptionPane.showMessageDialog(null, "PDF saved successfully!\n" + pdfPath, "Success",
                                JOptionPane.INFORMATION_MESSAGE);
                    } catch (IOException ioe) {
                        JOptionPane.showMessageDialog(null,
                                "Failed to write PDF. Please check permissions!\n" + ioe.getMessage(), "Failed",
                                JOptionPane.ERROR_MESSAGE);
                        ioe.printStackTrace();
                    }
                } catch (IOException ioe) {
                    JOptionPane.showMessageDialog(null, "Failed to create chart!\n" + ioe.getMessage(),
                            "Failed", JOptionPane.ERROR_MESSAGE);
                    ioe.printStackTrace();
                }
            } else {
                JOptionPane.showMessageDialog(null, "Failed to write PDF. Please check the file path!",
                        "Failed", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    btnPdf.setBounds(670, 475, 70, 23);
    btnPdf.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 11));
    btnPdf.setVisible(false);
    add(btnPdf);

    lblSelectProject = new JLabel("Select Project");
    lblSelectProject.setBounds(10, 65, 132, 14);
    lblSelectProject.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblSelectProject);

    lblSelectRooms = new JLabel("Select Rooms");
    lblSelectRooms.setBounds(10, 94, 132, 14);
    lblSelectRooms.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblSelectRooms);

    lblStartTime = new JLabel("Start Time");
    lblStartTime.setBounds(10, 123, 132, 14);
    lblStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(lblStartTime);

    lblWarning = new JLabel("Select 6 rooms and 1 cellar!");
    lblWarning.setForeground(Color.RED);
    lblWarning.setBounds(565, 123, 175, 14);
    lblWarning.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblWarning.setVisible(false);
    add(lblWarning);

    sliderStartTime = new JSlider();
    sliderStartTime.setMaximum(0);
    sliderStartTime.setBounds(152, 119, 285, 24);
    sliderStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(sliderStartTime);

    spnrStartTime = new JSpinner();
    spnrStartTime.setModel(new SpinnerNumberModel(0, 0, 0, 1));
    spnrStartTime.setBounds(447, 120, 108, 22);
    spnrStartTime.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(spnrStartTime);

    btnRefresh = new JButton("Load");
    btnRefresh.setBounds(616, 61, 124, 23);
    btnRefresh.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(btnRefresh);

    btnMaximize = new JButton("Fullscreen");
    btnMaximize.setBounds(10, 475, 124, 23);
    btnMaximize.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(btnMaximize);

    panelCampaign = new JPanel();
    panelCampaign.setBounds(10, 150, 730, 315);
    panelCampaign.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(panelCampaign);

    progressBar = new JProgressBar();
    progressBar.setBounds(10, 475, 730, 23);
    progressBar.setFont(new Font("SansSerif", Font.PLAIN, 11));
    progressBar.setVisible(false);
    add(progressBar);

    lblOpenOmbfile = new JLabel("Open OMB-File");
    lblOpenOmbfile.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblOpenOmbfile.setBounds(10, 36, 132, 14);
    add(lblOpenOmbfile);

    lblHelp = new JLabel("Select an OMB-Object file to manually simulate virtual campaigns.");
    lblHelp.setForeground(Color.GRAY);
    lblHelp.setFont(new Font("SansSerif", Font.PLAIN, 11));
    lblHelp.setBounds(10, 10, 730, 14);
    add(lblHelp);

    txtOmbFile = new JTextField();
    txtOmbFile.setFont(new Font("SansSerif", Font.PLAIN, 11));
    txtOmbFile.setColumns(10);
    txtOmbFile.setBounds(152, 33, 454, 20);
    add(txtOmbFile);

    btnBrowse = new JButton("Browse");
    btnBrowse.setFont(new Font("SansSerif", Font.PLAIN, 11));
    btnBrowse.setBounds(616, 32, 124, 23);
    add(btnBrowse);

    comboBoxRoom1 = new JComboBox<OMRoom>();
    comboBoxRoom1.setBounds(152, 90, 75, 22);
    comboBoxRoom1.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom1);

    comboBoxRoom2 = new JComboBox<OMRoom>();
    comboBoxRoom2.setBounds(237, 90, 75, 22);
    comboBoxRoom2.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom2);

    comboBoxRoom3 = new JComboBox<OMRoom>();
    comboBoxRoom3.setBounds(323, 90, 75, 22);
    comboBoxRoom3.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom3);

    comboBoxRoom4 = new JComboBox<OMRoom>();
    comboBoxRoom4.setBounds(408, 90, 75, 22);
    comboBoxRoom4.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom4);

    comboBoxRoom5 = new JComboBox<OMRoom>();
    comboBoxRoom5.setBounds(494, 90, 75, 22);
    comboBoxRoom5.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom5);

    comboBoxRoom6 = new JComboBox<OMRoom>();
    comboBoxRoom6.setBounds(579, 90, 75, 22);
    comboBoxRoom6.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom6);

    comboBoxRoom7 = new JComboBox<OMRoom>();
    comboBoxRoom7.setBounds(665, 90, 75, 22);
    comboBoxRoom7.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxRoom7);

    comboBoxProjects = new JComboBox<OMBuilding>();
    comboBoxProjects.setBounds(152, 61, 454, 22);
    comboBoxProjects.setFont(new Font("SansSerif", Font.PLAIN, 11));
    add(comboBoxProjects);

    comboBoxRoom1.addActionListener(this);
    comboBoxRoom1.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom2.addActionListener(this);
    comboBoxRoom2.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom3.addActionListener(this);
    comboBoxRoom3.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom4.addActionListener(this);
    comboBoxRoom4.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom5.addActionListener(this);
    comboBoxRoom5.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom6.addActionListener(this);
    comboBoxRoom6.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });
    comboBoxRoom7.addActionListener(this);
    comboBoxRoom7.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            validateCampaign();
        }
    });

    sliderStartTime.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (comboBoxProjects.isEnabled() || isResult) {
                if (comboBoxProjects.getSelectedItem() != null) {
                    spnrStartTime.setValue((int) sliderStartTime.getValue());
                    updateChart();
                }
            }
        }
    });
    spnrStartTime.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent arg0) {
            if (comboBoxProjects.isEnabled() || isResult) {
                if (comboBoxProjects.getSelectedItem() != null) {
                    sliderStartTime.setValue((Integer) spnrStartTime.getValue());
                    updateChart();
                }
            }
        }
    });
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (txtOmbFile.getText() != null && !txtOmbFile.getText().equals("")
                    && !txtOmbFile.getText().equals(" ")) {
                txtOmbFile.setBackground(Color.WHITE);
                String ombPath = txtOmbFile.getText();
                String omb;
                String[] tmpFileName = ombPath.split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("omb")) {
                    omb = "";
                } else {
                    omb = ".omb";
                }
                txtOmbFile.setText(ombPath + omb);
                setOmbFile(ombPath + omb);
                File ombFile = new File(ombPath + omb);
                if (ombFile.exists()) {
                    txtOmbFile.setBackground(Color.WHITE);
                    btnRefresh.setEnabled(false);
                    comboBoxProjects.setEnabled(false);
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    progressBar.setVisible(true);
                    btnPdf.setVisible(false);
                    btnCsv.setVisible(false);
                    btnMaximize.setVisible(false);
                    lblExportChartTo.setVisible(false);
                    progressBar.setIndeterminate(true);
                    progressBar.setStringPainted(true);
                    refreshTask = new Refresh();
                    refreshTask.execute();
                } else {
                    txtOmbFile.setBackground(new Color(255, 222, 222, 128));
                    JOptionPane.showMessageDialog(null, "OMB-file not found, please check the file path!",
                            "Error", JOptionPane.ERROR_MESSAGE);
                }
            } else {
                txtOmbFile.setBackground(new Color(255, 222, 222, 128));
                JOptionPane.showMessageDialog(null, "Please select an OMB-file!", "Warning",
                        JOptionPane.WARNING_MESSAGE);
            }
        }
    });
    btnMaximize.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            try {
                OMRoom[] rooms = new OMRoom[7];
                rooms[0] = (OMRoom) comboBoxRoom1.getSelectedItem();
                rooms[1] = (OMRoom) comboBoxRoom2.getSelectedItem();
                rooms[2] = (OMRoom) comboBoxRoom3.getSelectedItem();
                rooms[3] = (OMRoom) comboBoxRoom4.getSelectedItem();
                rooms[4] = (OMRoom) comboBoxRoom5.getSelectedItem();
                rooms[5] = (OMRoom) comboBoxRoom6.getSelectedItem();
                rooms[6] = (OMRoom) comboBoxRoom7.getSelectedItem();
                int start = sliderStartTime.getValue();
                String title = "Campaign: " + rooms[0].getId() + rooms[1].getId() + rooms[2].getId()
                        + rooms[3].getId() + rooms[4].getId() + rooms[5].getId() + rooms[6].getId()
                        + ", Start: " + start;
                OMCampaign campaign;
                if (isResult) {
                    campaign = getResultCampaign();
                } else {
                    campaign = new OMCampaign(start, rooms, 0);
                }
                JPanel campaignChart = createCampaignPanel(campaign, false, true);
                JFrame chartFrame = new JFrame();
                chartFrame.getContentPane().add(campaignChart);
                chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                chartFrame.setBounds(0, 0, (int) dim.getWidth(), (int) dim.getHeight());
                chartFrame.setTitle(title);
                chartFrame.setResizable(true);
                chartFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
                chartFrame.setVisible(true);
            } catch (IOException ioe) {
                ioe.printStackTrace();
            }
        }
    });
    txtOmbFile.addFocusListener(new FocusAdapter() {
        @Override
        public void focusLost(FocusEvent arg0) {
            setOmbFile(txtOmbFile.getText());
        }
    });
    btnBrowse.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            JFileChooser fileDialog = new JFileChooser();
            fileDialog.setFileFilter(new FileNameExtensionFilter("*.omb", "omb"));
            fileDialog.showOpenDialog(getParent());
            final File file = fileDialog.getSelectedFile();
            if (file != null) {
                String omb;
                String[] tmpFileName = file.getAbsolutePath().split("\\.");
                if (tmpFileName[tmpFileName.length - 1].equals("omb")) {
                    omb = "";
                } else {
                    omb = ".omb";
                }
                txtOmbFile.setText(file.getAbsolutePath() + omb);
                setOmbFile(file.getAbsolutePath() + omb);
            }
        }
    });
}

From source file:ffx.algorithms.TransitionTemperedOSRW.java

@Override
public double energyAndGradient(double[] x, double[] gradient) {

    double e = potential.energyAndGradient(x, gradient);

    /**//from w w w . j  a  v  a2  s .c  om
     * OSRW is propagated with the slowly varying terms.
     */
    if (state == STATE.FAST) {
        return e;
    }

    if (osrwOptimization && lambda > osrwOptimizationLambdaCutoff) {
        if (energyCount % osrwOptimizationFrequency == 0) {
            logger.info(String.format(" OSRW Minimization (Step %d)", energyCount));

            // Set Lambda value to 1.0.
            lambdaInterface.setLambda(1.0);

            potential.setEnergyTermState(Potential.STATE.BOTH);

            // Optimize the system.
            Minimize minimize = new Minimize(null, potential, null);
            minimize.minimize(osrwOptimizationEps);

            // Collect the minimum energy.
            double minEnergy = potential.getTotalEnergy();
            // If a new minimum has been found, save its coordinates.
            if (minEnergy < osrwOptimum) {
                osrwOptimum = minEnergy;
                logger.info(String.format(" New minimum energy found: %16.8f (Step %d).", osrwOptimum,
                        energyCount));
                int n = potential.getNumberOfVariables();
                osrwOptimumCoords = new double[n];
                osrwOptimumCoords = potential.getCoordinates(osrwOptimumCoords);
                if (pdbFilter.writeFile(pdbFile, false)) {
                    logger.info(String.format(" Wrote PDB file to " + pdbFile.getName()));
                }
            }

            // Reset lambda value.
            lambdaInterface.setLambda(lambda);

            // Remove the scaling of coordinates & gradient set by the minimizer.
            potential.setScaling(null);

            // Reset the Potential State
            potential.setEnergyTermState(state);

            // Revert to the coordinates and gradient prior to optimization.
            double eCheck = potential.energyAndGradient(x, gradient);

            if (abs(eCheck - e) > osrwOptimizationTolerance) {
                logger.warning(String.format(
                        " OSRW optimization could not revert coordinates %16.8f vs. %16.8f.", e, eCheck));
            }
        }
    }

    double biasEnergy = 0.0;
    dEdLambda = lambdaInterface.getdEdL();
    d2EdLambda2 = lambdaInterface.getd2EdL2();
    int lambdaBin = binForLambda(lambda);
    int FLambdaBin = binForFLambda(dEdLambda);
    double dEdU = dEdLambda;

    if (propagateLambda) {
        energyCount++;
        detectTransition();
    }

    /**
     * Calculate recursion kernel G(L, F_L) and its derivatives with respect
     * to L and F_L.
     */
    double dGdLambda = 0.0;
    double dGdFLambda = 0.0;
    double ls2 = (2.0 * dL) * (2.0 * dL);
    double FLs2 = (2.0 * dFL) * (2.0 * dFL);
    for (int iL = -biasCutoff; iL <= biasCutoff; iL++) {
        int lcenter = lambdaBin + iL;
        double deltaL = lambda - (lcenter * dL);
        double deltaL2 = deltaL * deltaL;
        // Mirror conditions for recursion kernel counts.
        int lcount = lcenter;
        double mirrorFactor = 1.0;
        if (lcount == 0 || lcount == lambdaBins - 1) {
            mirrorFactor = 2.0;
        } else if (lcount < 0) {
            lcount = -lcount;
        } else if (lcount > lambdaBins - 1) {
            // Number of bins past the last bin
            lcount -= (lambdaBins - 1);
            // Mirror bin
            lcount = lambdaBins - 1 - lcount;
        }
        for (int iFL = -biasCutoff; iFL <= biasCutoff; iFL++) {
            int FLcenter = FLambdaBin + iFL;
            /**
             * If either of the following FL edge conditions are true, then
             * there are no counts and we continue.
             */
            if (FLcenter < 0 || FLcenter >= FLambdaBins) {
                continue;
            }
            double deltaFL = dEdLambda - (minFLambda + FLcenter * dFL + dFL_2);
            double deltaFL2 = deltaFL * deltaFL;
            double weight = mirrorFactor * recursionKernel[lcount][FLcenter];
            double bias = weight * biasMag * exp(-deltaL2 / (2.0 * ls2)) * exp(-deltaFL2 / (2.0 * FLs2));
            biasEnergy += bias;
            dGdLambda -= deltaL / ls2 * bias;
            dGdFLambda -= deltaFL / FLs2 * bias;
        }
    }

    /**
     * Lambda gradient due to recursion kernel G(L, F_L).
     */
    dEdLambda += dGdLambda + dGdFLambda * d2EdLambda2;

    /**
     * Cartesian coordinate gradient due to recursion kernel G(L, F_L).
     */
    fill(dUdXdL, 0.0);
    lambdaInterface.getdEdXdL(dUdXdL);
    for (int i = 0; i < nVariables; i++) {
        gradient[i] += dGdFLambda * dUdXdL[i];
    }

    if (propagateLambda && energyCount > 0) {
        /**
         * Update free energy F(L) every ~10 steps.
         */
        if (energyCount % 10 == 0) {
            fLambdaUpdates++;
            boolean printFLambda = fLambdaUpdates % fLambdaPrintInterval == 0;
            totalFreeEnergy = updateFLambda(printFLambda);
            /**
             * Calculating Moving Average & Standard Deviation
             */
            totalAverage += totalFreeEnergy;
            totalSquare += Math.pow(totalFreeEnergy, 2);
            periodCount++;
            if (periodCount == window - 1) {
                lastAverage = totalAverage / window;
                //lastStdDev = Math.sqrt((totalSquare - Math.pow(totalAverage, 2) / window) / window);
                lastStdDev = Math.sqrt((totalSquare - (totalAverage * totalAverage)) / (window * window));
                logger.info(String.format(
                        " The running average is %12.4f kcal/mol and the stdev is %8.4f kcal/mol.", lastAverage,
                        lastStdDev));
                totalAverage = 0;
                totalSquare = 0;
                periodCount = 0;
            }
        }
        if (energyCount % saveFrequency == 0) {
            if (algorithmListener != null) {
                algorithmListener.algorithmUpdate(lambdaOneAssembly);
            }
            /**
             * Only the rank 0 process writes the histogram restart file.
             */
            if (rank == 0) {
                try {
                    TTOSRWHistogramWriter ttOSRWHistogramRestart = new TTOSRWHistogramWriter(
                            new BufferedWriter(new FileWriter(histogramFile)));
                    ttOSRWHistogramRestart.writeHistogramFile();
                    ttOSRWHistogramRestart.flush();
                    ttOSRWHistogramRestart.close();
                    logger.info(String.format(" Wrote TTOSRW histogram restart file to %s.",
                            histogramFile.getName()));
                } catch (IOException ex) {
                    String message = " Exception writing TTOSRW histogram restart file.";
                    logger.log(Level.INFO, message, ex);
                }
            }
            /**
             * All ranks write a lambda restart file.
             */
            try {
                TTOSRWLambdaWriter ttOSRWLambdaRestart = new TTOSRWLambdaWriter(
                        new BufferedWriter(new FileWriter(lambdaFile)));
                ttOSRWLambdaRestart.writeLambdaFile();
                ttOSRWLambdaRestart.flush();
                ttOSRWLambdaRestart.close();
                logger.info(String.format(" Wrote TTOSRW lambda restart file to %s.", lambdaFile.getName()));
            } catch (IOException ex) {
                String message = " Exception writing TTOSRW lambda restart file.";
                logger.log(Level.INFO, message, ex);
            }
        }
        /**
         * Write out snapshot upon each full lambda traversal.
         */
        if (writeTraversalSnapshots) {
            double heldTraversalLambda = 0.5;
            if (!traversalInHand.isEmpty()) {
                heldTraversalLambda = Double.parseDouble(traversalInHand.get(0).split(",")[0]);
                if ((lambda > 0.2 && traversalSnapshotTarget == 0)
                        || (lambda < 0.8 && traversalSnapshotTarget == 1)) {
                    int snapshotCounts = Integer.parseInt(traversalInHand.get(0).split(",")[1]);
                    traversalInHand.remove(0);
                    File fileToWrite;
                    int numStructures;
                    if (traversalSnapshotTarget == 0) {
                        fileToWrite = lambdaZeroFile;
                        numStructures = ++lambdaZeroStructures;
                    } else {
                        fileToWrite = lambdaOneFile;
                        numStructures = ++lambdaOneStructures;
                    }
                    try {
                        FileWriter fw = new FileWriter(fileToWrite, true);
                        BufferedWriter bw = new BufferedWriter(fw);
                        bw.write(String.format("MODEL        %d          L=%.4f  counts=%d", numStructures,
                                heldTraversalLambda, snapshotCounts));
                        for (int i = 0; i < 50; i++) {
                            bw.write(" ");
                        }
                        bw.newLine();
                        for (int i = 0; i < traversalInHand.size(); i++) {
                            bw.write(traversalInHand.get(i));
                            bw.newLine();
                        }
                        bw.write(String.format("ENDMDL"));
                        for (int i = 0; i < 75; i++) {
                            bw.write(" ");
                        }
                        bw.newLine();
                        bw.close();
                        logger.info(String.format(" Wrote traversal structure L=%.4f", heldTraversalLambda));
                    } catch (Exception exception) {
                        logger.warning(String.format("Exception writing to file: %s", fileToWrite.getName()));
                    }
                    heldTraversalLambda = 0.5;
                    traversalInHand.clear();
                    traversalSnapshotTarget = 1 - traversalSnapshotTarget;
                }
            }
            if (((lambda < 0.1 && traversalInHand.isEmpty())
                    || (lambda < heldTraversalLambda - 0.025 && !traversalInHand.isEmpty()))
                    && (traversalSnapshotTarget == 0 || traversalSnapshotTarget == -1)) {
                if (lambdaZeroFilter == null) {
                    lambdaZeroFilter = new PDBFilter(lambdaZeroFile, lambdaZeroAssembly, null, null);
                    lambdaZeroFilter.setListMode(true);
                }
                lambdaZeroFilter.clearListOutput();
                lambdaZeroFilter.writeFileWithHeader(lambdaFile,
                        new StringBuilder(String.format("%.4f,%d", lambda, totalWeight)));
                traversalInHand = lambdaZeroFilter.getListOutput();
                traversalSnapshotTarget = 0;
            } else if (((lambda > 0.9 && traversalInHand.isEmpty())
                    || (lambda > heldTraversalLambda + 0.025 && !traversalInHand.isEmpty()))
                    && (traversalSnapshotTarget == 1 || traversalSnapshotTarget == -1)) {
                if (lambdaOneFilter == null) {
                    lambdaOneFilter = new PDBFilter(lambdaOneFile, lambdaOneAssembly, null, null);
                    lambdaOneFilter.setListMode(true);
                }
                lambdaOneFilter.clearListOutput();
                lambdaOneFilter.writeFileWithHeader(lambdaFile,
                        new StringBuilder(String.format("%.4f,%d", lambda, totalWeight)));
                traversalInHand = lambdaOneFilter.getListOutput();
                traversalSnapshotTarget = 1;
            }
        }
    }

    /**
     * Compute the energy and gradient for the recursion slave at F(L) using
     * interpolation.
     */
    double freeEnergy = currentFreeEnergy();
    biasEnergy += freeEnergy;

    if (print) {
        logger.info(String.format(" %s %16.8f", "Bias Energy       ", biasEnergy));
        logger.info(String.format(" %s %16.8f  %s", "OSRW Potential    ", e + biasEnergy, "(Kcal/mole)"));
    }

    if (propagateLambda && energyCount > 0) {
        /**
         * Log the current Lambda state.
         */
        if (energyCount % printFrequency == 0) {
            if (lambdaBins < 1000) {
                logger.info(String.format(" L=%6.4f (%3d) F_LU=%10.4f F_LB=%10.4f F_L=%10.4f", lambda,
                        lambdaBin, dEdU, dEdLambda - dEdU, dEdLambda));
            } else {
                logger.info(String.format(" L=%6.4f (%4d) F_LU=%10.4f F_LB=%10.4f F_L=%10.4f", lambda,
                        lambdaBin, dEdU, dEdLambda - dEdU, dEdLambda));
            }
        }

        /**
         * Metadynamics grid counts (every 'countInterval' steps).
         */
        if (energyCount % countInterval == 0) {
            if (jobBackend != null) {
                if (world.size() > 1) {
                    jobBackend.setComment(String.format(
                            "Overall dG=%10.4f at %7.3e psec, Current: [L=%6.4f, F_L=%10.4f, dG=%10.4f] at %7.3e psec",
                            totalFreeEnergy, totalWeight * dt * countInterval, lambda, dEdU, -freeEnergy,
                            energyCount * dt));
                } else {
                    jobBackend.setComment(String.format(
                            "Overall dG=%10.4f at %7.3e psec, Current: [L=%6.4f, F_L=%10.4f, dG=%10.4f]",
                            totalFreeEnergy, totalWeight * dt * countInterval, lambda, dEdU, -freeEnergy));
                }
            }
            if (asynchronous) {
                asynchronousSend(lambda, dEdU);
            } else {
                synchronousSend(lambda, dEdU);
            }
        }
    }

    /**
     * Propagate the Lambda particle.
     */
    if (propagateLambda) {
        langevin();
    } else {
        equilibrationCounts++;
        if (jobBackend != null) {
            jobBackend.setComment(String.format("Equilibration [L=%6.4f, F_L=%10.4f]", lambda, dEdU));
        }
        if (equilibrationCounts % 10 == 0) {
            logger.info(String.format(" L=%6.4f, F_L=%10.4f", lambda, dEdU));
        }
    }

    totalEnergy = e + biasEnergy;

    return totalEnergy;
}

From source file:com.cisco.dvbu.ps.common.util.CommonUtils.java

/**
 * Append passed in content to the file.
 * Create file if it does not exist.  /*from   www  .  java  2  s .  c  o  m*/
 * Create the sub-directories if they do not exist.
 * 
 * @param file - file name with path
 * @param content - the content to append to the file
 */
public static void appendContentToFile(String file, String content) {

    if (file == null || file.length() <= 0) {
        throw new CompositeException("File path is not defined.");
    }

    // Create the sub-directories if they do not already exist
    String fileDir = getDirectory(file);
    if (fileDir != null && !fileExists(fileDir)) {
        mkdirs(fileDir);
    }
    // Write to the file
    BufferedWriter bw = null;
    try {
        if (file != null && file.trim().length() > 0) {
            bw = new BufferedWriter(new FileWriter(file, true));
            if (content != null && content.trim().length() > 0) {

                bw.write(content);
                bw.newLine();
                bw.flush();
            }
        }
    } catch (IOException e) {
        CompositeLogger.logException(e, "Could not append to file " + file);
        throw new ValidationException(e.getMessage(), e);
    } finally { // always close the file
        if (bw != null)
            try {
                bw.close();
            } catch (IOException ioe2) {
                // just ignore it
            }
    } // end try/catch/finally
}

From source file:de.tudarmstadt.ukp.dkpro.core.io.ditop.DiTopWriter.java

/**
 * This method has been copied and slightly adapted from MalletLDA#printTopics in the original
 * DiTop code./*from   w w w  . j  a  va 2 s .  c  o  m*/
 *
 * @throws IOException
 *             if a low-level I/O error occurs
 */
private void writetermMatrixFiles() throws IOException {
    File topicTermFile = new File(collectionDir, TOPIC_TERM_FILE);
    File topicTermMatrixFile = new File(collectionDir, TOPIC_TERM_MATRIX_FILE);
    File topicSummaryFile = new File(collectionDir, TOPIC_SUMMARY_FILE);

    BufferedWriter writerTopicTerm = new BufferedWriter(new FileWriter(topicTermFile));
    BufferedWriter writerTopicTermMatrix = new BufferedWriter(new FileWriter(topicTermMatrixFile));
    BufferedWriter writerTopicTermShort = new BufferedWriter(new FileWriter(topicSummaryFile));

    getLogger().info(String.format("Writing file '%s'.", topicTermFile));
    getLogger().info(String.format("Writing file '%s'.", topicTermMatrixFile));
    getLogger().info(String.format("Writing file '%s'.", topicSummaryFile));

    /* Write topic term associations */
    Alphabet alphabet = model.getAlphabet();
    for (int i = 0; i < model.getSortedWords().size(); i++) {
        writerTopicTerm.write("TOPIC " + i + ": ");
        writerTopicTermShort.write("TOPIC " + i + ": ");
        writerTopicTermMatrix.write("TOPIC " + i + ": ");
        /** topic for the label */
        int count = 0;
        TreeSet<IDSorter> set = model.getSortedWords().get(i);
        for (IDSorter s : set) {
            if (count <= maxTopicWords) {
                writerTopicTermShort.write(alphabet.lookupObject(s.getID()) + ", ");
            }
            count++;
            writerTopicTerm.write(alphabet.lookupObject(s.getID()) + ", ");
            writerTopicTermMatrix.write(alphabet.lookupObject(s.getID()) + " (" + s.getWeight() + "), ");
            /** add to topic label */
        }
        writerTopicTerm.newLine();
        writerTopicTermShort.newLine();
        writerTopicTermMatrix.newLine();
    }

    writerTopicTermMatrix.close();
    writerTopicTerm.close();
    writerTopicTermShort.close();
}

From source file:it.unibas.spicy.persistence.csv.ExportCSVInstances.java

private void appendToCSVDocument(ResultSet allRows, int columnCount, String filePath)
        throws SQLException, IOException {
    //the flag 'true' means that the writer will go to the end of the file and append the new data
    BufferedWriter bfout = new BufferedWriter(new FileWriter(filePath, true));
    try {/*from w w w  .  j  a v  a 2  s.co  m*/
        while (allRows.next()) {
            String row = "";
            for (int j = 1; j <= columnCount; j++) {
                String dataType = allRows.getMetaData().getColumnTypeName(j);
                String value = allRows.getString(j);
                //if the value is null write null to csv file
                if (value == null) {
                    //                        avenet 20170215 - using "" is the copy csv format for Postgres
                    value = "";
                }
                //if the type is String/text etc and is not null put the value between double quotes
                else if (dataType.toLowerCase().startsWith("varchar")
                        || dataType.toLowerCase().startsWith("char")
                        || dataType.toLowerCase().startsWith("text") || dataType.equalsIgnoreCase("bpchar")
                        || dataType.equalsIgnoreCase("bit") || dataType.equalsIgnoreCase("mediumtext")
                        || dataType.equalsIgnoreCase("longtext") || dataType.equalsIgnoreCase("serial")
                        || dataType.equalsIgnoreCase("enum")) {
                    value = "\"" + value + "\"";
                }
                row = row + value + ",";
            }
            //take out the last ',' character
            row = row.substring(0, row.length() - 1);
            bfout.write(row);
            bfout.newLine();
        }
    } finally {
        bfout.close();
    }
}

From source file:com.holycityaudio.SpinCAD.SpinCADFile.java

public void fileSaveHex(int patchIndex, int[] codeListing, String fileName) throws IOException {
    BufferedWriter writer = new BufferedWriter(new FileWriter(fileName, true));
    int i = -1;// w  w w  .  j av  a2s  .  c o m
    String outputString = new String();
    for (int ii = 0, index = 0; ii < 128; ii++) {
        if (ii < codeListing.length) {
            i = codeListing[ii];
        } else {
            i = 0;
        }
        if (i != -1) {
            if (i == 0) { // do NOP conversion
                i = 0x11;
            }
            outputString = String.format("04%04X00%08X", (patchIndex * 0x200) + index, i);
            //            outputString = String.format("04%04X00%08X", index, i);
            long message = Long.parseLong(outputString, 16);
            int checksum = 0;
            for (int iii = 0; iii < 8; iii++) {
                checksum = checksum + (int) (message & 0xff);
                message = message >> 8;
            }
            checksum = (((~checksum) & 0xff) + 1) & 0xff;
            writer.write(":" + outputString + String.format("%02X", checksum));
            writer.newLine();
            index += 4;
        }
    }
    if (patchIndex == 7) {
        writer.write(":00000001FF\n");
    }
    writer.close();
}

From source file:io.snappydata.hydra.cluster.SnappyTest.java

/**
 * Task(ENDTASK) for cleaning up snappy processes, because they are not stopped by Hydra in case of Test failure.
 *///from  w w w  .j av  a  2s.c om
public static void HydraTask_cleanUpSnappyProcessesOnFailure() {
    Process pr = null;
    ProcessBuilder pb = null;
    File logFile = null, log = null, nukeRunOutput = null;
    try {
        List<String> pidList = new ArrayList();
        HostDescription hd = TestConfig.getInstance().getMasterDescription().getVmDescription()
                .getHostDescription();
        pidList = snappyTest.getPidList();
        log = new File(".");
        String nukerun = log.getCanonicalPath() + File.separator + "snappyNukeRun.sh";
        logFile = new File(nukerun);
        String nukeRunOutputString = log.getCanonicalPath() + File.separator + "nukeRunOutput.log";
        nukeRunOutput = new File(nukeRunOutputString);
        FileWriter fw = new FileWriter(logFile.getAbsoluteFile(), true);
        BufferedWriter bw = new BufferedWriter(fw);
        for (String pidString : pidList) {
            int pid = Integer.parseInt(pidString);
            bw.write("/bin/kill -KILL " + pid);
            bw.newLine();
            try {
                RemoteTestModule.Master.removePID(hd, pid);
            } catch (RemoteException e) {
                String s = "Failed to remove PID from nukerun script: " + pid;
                throw new HydraRuntimeException(s, e);
            }
        }
        bw.close();
        fw.close();
        logFile.setExecutable(true);
        pb = new ProcessBuilder(nukerun);
        pb.redirectErrorStream(true);
        pb.redirectOutput(ProcessBuilder.Redirect.appendTo(nukeRunOutput));
        pr = pb.start();
        pr.waitFor();
    } catch (IOException e) {
        throw new TestException("IOException occurred while retriving logFile path " + log + "\nError Message:"
                + e.getMessage());
    } catch (InterruptedException e) {
        String s = "Exception occurred while waiting for the process execution : " + pr;
        throw new TestException(s, e);
    }
}