Example usage for java.io PrintWriter println

List of usage examples for java.io PrintWriter println

Introduction

In this page you can find the example usage for java.io PrintWriter println.

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminates the line.

Usage

From source file:de.tudarmstadt.ukp.dkpro.tc.svmhmm.util.SVMHMMUtils.java

/**
 * Given confusion matrix, it writes it in CSV and LaTeX form to the tasks output directory,
 * and also prints evaluations (F-measure, Precision, Recall)
 *
 * @param context         task context/*from  w w  w  .  ja  v a2s .c  om*/
 * @param confusionMatrix confusion matrix
 * @param filePrefix      prefix of output files
 * @throws java.io.IOException
 */
public static void writeOutputResults(TaskContext context, ConfusionMatrix confusionMatrix, String filePrefix)
        throws IOException {
    // storing the results as latex confusion matrix
    String confMatrixFileTex = (filePrefix != null ? filePrefix : "") + "confusionMatrix.tex";
    File evaluationFileLaTeX = new File(
            context.getStorageLocation(Constants.TEST_TASK_OUTPUT_KEY, StorageService.AccessMode.READWRITE),
            confMatrixFileTex);
    FileUtils.writeStringToFile(evaluationFileLaTeX, confusionMatrix.toStringLatex());

    // as CSV confusion matrix
    String confMatrixFileCsv = (filePrefix != null ? filePrefix : "") + "confusionMatrix.csv";
    File evaluationFileCSV = new File(
            context.getStorageLocation(Constants.TEST_TASK_OUTPUT_KEY, StorageService.AccessMode.READWRITE),
            confMatrixFileCsv);

    CSVPrinter csvPrinter = new CSVPrinter(new FileWriter(evaluationFileCSV), CSVFormat.DEFAULT);
    csvPrinter.printRecords(confusionMatrix.toStringMatrix());
    IOUtils.closeQuietly(csvPrinter);

    // and results
    File evaluationFile = new File(
            context.getStorageLocation(Constants.TEST_TASK_OUTPUT_KEY, StorageService.AccessMode.READWRITE),
            new SVMHMMAdapter()
                    .getFrameworkFilename(TCMachineLearningAdapter.AdapterNameEntries.evaluationFile));

    PrintWriter pw = new PrintWriter(evaluationFile);
    pw.println(confusionMatrix.printNiceResults());
    pw.println(confusionMatrix.printLabelPrecRecFm());
    pw.println(confusionMatrix.printClassDistributionGold());
    IOUtils.closeQuietly(pw);
}

From source file:edu.gmu.csiss.automation.pacs.utils.BaseTool.java

/**
 * Write string to file/*from   w  w  w .j  av  a 2 s  .  c om*/
 * @param content
 * @param filepath
 */
public static void writeString2File(String content, String filepath) {
    PrintWriter out;
    try {
        out = new PrintWriter(filepath);
        out.println(content);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:eu.annocultor.tools.GeneratorOfXmlSchemaForConvertersDoclet.java

static void printRuleDocEnd(PrintWriter out) throws Exception {
    out.println(" </body>");
    out.println("</document>");
    out.println();//  www .j ava  2 s.c  om
    out.flush();
    out.close();
}

From source file:gov.nih.nci.evs.testUtil.BaseUITestGenerator.java

public static void printImportStatements(PrintWriter out) {
    out.println("import gov.nih.nci.evs.testUtil.ui.*;");
    out.println("import gov.nih.nci.evs.testUtil.*;");
    out.println("import gov.nih.nci.evs.browser.utils.*;");
    out.println("import gov.nih.nci.evs.browser.common.*;");
    out.println("import gov.nih.nci.evs.security.SecurityToken;");
    out.println("import gov.nih.nci.system.client.ApplicationServiceProvider;");
    out.println("import java.io.File;");
    out.println("import java.io.IOException;");
    out.println("import java.net.*;");
    out.println("import java.text.SimpleDateFormat;");
    out.println("import java.util.Date;");
    out.println("import java.util.Iterator;");
    out.println("import java.util.List;");
    out.println("import java.util.Set;");
    out.println("import java.util.HashSet;");
    out.println("import java.util.Vector;");
    out.println("import java.util.concurrent.TimeUnit;");
    out.println("import org.LexGrid.LexBIG.DataModel.Collections.*;");
    out.println("import org.LexGrid.LexBIG.DataModel.Collections.CodingSchemeRenderingList;");
    out.println("import org.LexGrid.LexBIG.DataModel.Collections.ModuleDescriptionList;");
    out.println("import org.LexGrid.LexBIG.DataModel.Collections.ResolvedConceptReferenceList;");
    out.println("import org.LexGrid.LexBIG.DataModel.Core.*;");
    out.println("import org.LexGrid.LexBIG.DataModel.Core.AbsoluteCodingSchemeVersionReference;");
    out.println("import org.LexGrid.LexBIG.DataModel.Core.CodingSchemeVersionOrTag;");
    out.println("import org.LexGrid.LexBIG.DataModel.Core.ResolvedConceptReference;");
    out.println("import org.LexGrid.LexBIG.DataModel.Core.types.*;");
    out.println("import org.LexGrid.LexBIG.DataModel.InterfaceElements.*;");
    out.println("import org.LexGrid.LexBIG.DataModel.InterfaceElements.CodingSchemeRendering;");
    out.println("import org.LexGrid.LexBIG.DataModel.InterfaceElements.ModuleDescription;");
    out.println("import org.LexGrid.LexBIG.Exceptions.*;");
    out.println("import org.LexGrid.LexBIG.Exceptions.LBException;");
    out.println("import org.LexGrid.LexBIG.Extensions.Generic.*;");
    out.println("import org.LexGrid.LexBIG.Extensions.Generic.CodingSchemeReference;");
    out.println("import org.LexGrid.LexBIG.Extensions.Generic.LexBIGServiceConvenienceMethods.*;");
    out.println("import org.LexGrid.LexBIG.Extensions.Generic.SearchExtension;");
    out.println("import org.LexGrid.LexBIG.LexBIGService.*;");
    out.println("import org.LexGrid.LexBIG.LexBIGService.CodedNodeSet.*;");
    out.println("import org.LexGrid.LexBIG.LexBIGService.CodedNodeSet;");
    out.println("import org.LexGrid.LexBIG.LexBIGService.LexBIGService;");
    out.println("import org.LexGrid.LexBIG.Utility.*;");
    out.println("import org.LexGrid.LexBIG.Utility.Constructors;");
    out.println("import org.LexGrid.LexBIG.Utility.Iterators.*;");
    out.println("import org.LexGrid.LexBIG.Utility.Iterators.ResolvedConceptReferencesIterator;");
    out.println("import org.LexGrid.LexBIG.caCore.interfaces.LexEVSDistributed;");
    out.println("import org.LexGrid.codingSchemes.*;");
    out.println("import org.LexGrid.codingSchemes.CodingScheme;");
    out.println("import org.LexGrid.concepts.*;");
    out.println("import org.LexGrid.naming.*;");
    out.println("import org.apache.commons.codec.language.*;");
    out.println("import org.apache.commons.io.FileUtils;");
    out.println("import org.apache.log4j.*;");
    out.println("import org.junit.*;");
    out.println("import org.junit.Assert;");
    out.println("import org.openqa.selenium.Alert;");
    out.println("import org.openqa.selenium.By;");
    out.println("import org.openqa.selenium.JavascriptExecutor;");
    out.println("import org.openqa.selenium.Keys;");
    out.println("import org.openqa.selenium.NoAlertPresentException;");
    out.println("import org.openqa.selenium.NoSuchElementException;");
    out.println("import org.openqa.selenium.OutputType;");
    out.println("import org.openqa.selenium.TakesScreenshot;");
    out.println("import org.openqa.selenium.WebDriver;");
    out.println("import org.openqa.selenium.WebElement;");
    out.println("import org.openqa.selenium.chrome.ChromeDriver;");
    out.println("import org.openqa.selenium.chrome.ChromeOptions;");
    out.println("import org.openqa.selenium.firefox.FirefoxBinary;");
    out.println("import org.openqa.selenium.firefox.FirefoxDriver;");
    out.println("import org.openqa.selenium.firefox.FirefoxProfile;");
    out.println("import org.openqa.selenium.ie.InternetExplorerDriver;");
    out.println("import org.openqa.selenium.interactions.Actions;");
    out.println("import org.openqa.selenium.remote.DesiredCapabilities;");
    out.println("import org.openqa.selenium.remote.RemoteWebDriver;");
    out.println("import org.openqa.selenium.support.ui.ExpectedConditions;");
    out.println("import org.openqa.selenium.support.ui.Select;");
    out.println("import org.openqa.selenium.support.ui.WebDriverWait;");
    out.println("import static org.junit.Assert.*;");
    out.println("\n");
}

From source file:gov.nih.nci.evs.testUtil.BaseUITestGenerator.java

public static void printSetUp(PrintWriter out, String CHROME_SERVER_URL, String baseUrl, String serviceUrl) {
    out.println("  @Before");
    out.println("  public void setUp() throws Exception {");
    out.println("    //driver = new FirefoxDriver();");
    out.println("    driver = new RemoteWebDriver(new URL(\"" + CHROME_SERVER_URL
            + "\"), DesiredCapabilities.chrome());");
    out.println("    serviceUrl = \"" + serviceUrl + "\";");
    out.println("    baseUrl = \"" + baseUrl + "\";");
    out.println("    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);");
    out.println("    driver.get(baseUrl + \"/ncitbrowser/pages/multiple_search.jsf\");");
    out.println("");
    out.println("    lbSvc = LexEVSServiceUtil.getLexBIGService(serviceUrl);");
    out.println("    simpleSearchUtils = new SimpleSearchUtils(lbSvc);");
    out.println("    mappingSearchUtils = new MappingSearchUtils(lbSvc);");
    out.println("    valueSetSearchUtils = new ValueSetSearchUtils(lbSvc);");
    out.println("  }");
    out.println("");
}

From source file:io.warp10.worf.WorfCLI.java

private static int runInteractive(String warp10Configuration) throws WorfException {
    WorfInteractive worfInteractive = new WorfInteractive();
    PrintWriter out = worfInteractive.getPrintWriter();

    // read warp10 configuration
    out.println("Reading warp10 configuration " + warp10Configuration);
    Properties config = Worf.readConfig(warp10Configuration, out);

    if (config == null) {
        out.println("Unable to read warp10 configuration.");
        out.flush();//from w  ww  .jav  a2 s.  c  o  m
        return -1;
    }

    if (WorfTemplate.isTemplate(config)) {
        warp10Configuration = worfInteractive.runTemplate(config, warp10Configuration);
        // reload config
        config = Worf.readConfig(warp10Configuration, out);
    }
    // get Default values
    Properties worfConfig = Worf.readDefault(warp10Configuration, out);
    worfInteractive.run(config, worfConfig);

    return 0;
}

From source file:es.csic.iiia.planes.cli.Cli.java

/**
 * Parse the provided list of arguments according to the program's options.
 * /*from  ww  w.java  2s  . com*/
 * @param in_args
 *            list of input arguments.
 * @return a configuration object set according to the input options.
 */
private static Configuration parseOptions(String[] in_args) {
    CommandLineParser parser = new PosixParser();
    CommandLine line = null;
    Properties settings = loadDefaultSettings();

    try {
        line = parser.parse(options, in_args);
    } catch (ParseException ex) {
        Logger.getLogger(Cli.class.getName()).log(Level.SEVERE, ex.getLocalizedMessage(), ex);
        showHelp();
    }

    if (line.hasOption('h')) {
        showHelp();
    }

    if (line.hasOption('d')) {
        dumpSettings();
    }

    if (line.hasOption('s')) {
        String fname = line.getOptionValue('s');
        try {
            settings.load(new FileReader(fname));
        } catch (IOException ex) {
            throw new IllegalArgumentException("Unable to load the settings file \"" + fname + "\"");
        }
    }

    // Apply overrides
    settings.setProperty("gui", String.valueOf(line.hasOption('g')));
    settings.setProperty("quiet", String.valueOf(line.hasOption('q')));
    Properties overrides = line.getOptionProperties("o");
    settings.putAll(overrides);

    String[] args = line.getArgs();
    if (args.length < 1) {
        showHelp();
    }
    settings.setProperty("problem", args[0]);

    Configuration c = new Configuration(settings);
    System.out.println(c.toString());
    /**
     * Modified by Guillermo B. Print settings to a result file, titled
     * "results.txt"
     */
    try {
        FileWriter fw = new FileWriter("results.txt", true);
        BufferedWriter bw = new BufferedWriter(fw);
        PrintWriter out = new PrintWriter(bw);
        String[] results = c.toString().split("\n");
        // out.println(results[8]);

        for (String s : results) {
            out.println(s);

        }
        // out.println(results[2]);
        // out.println(results[8]);
        out.close();
    } catch (IOException e) {
    }

    /**
     * Modified by Ebtesam Save settings to a .csv file, titled
     * "resultsCSV.csv"
     */

    try {
        FileWriter writer = new FileWriter("resultsCSV.csv", true);
        FileReader reader = new FileReader("resultsCSV.csv");

        String header = "SAR Strategy,# of Searcher UAVs,# of Survivors,"
                + "# of Survivors rescued,Min.Time needed to rescue Survivors,Mean. Time needed to rescue Survivors,Max. Time needed to rescue Survivors,"
                + "# of Survivors found,Min. Time needed to find Survivors,Mean Time needed to find Survivors,Max. Time needed to find Survivors,"
                + "Running Time of Simulation\n";
        if (reader.read() == -1) {
            writer.append(header);
            writer.append("\n");
        }
        reader.close();
        String[] results = c.toString().split("\n");
        writer.append(results[2].substring(10));
        writer.append(",");
        writer.append(results[20].substring(11));
        writer.append(",");
        writer.append(results[30].substring(18));
        writer.write(",");
        writer.close();
    } catch (IOException e) {
    }

    if (line.hasOption('t')) {
        System.exit(0);
    }
    return c;
}

From source file:gov.nih.nci.evs.testUtil.BaseUITestGenerator.java

public static void printWindowUtils(PrintWriter out) {
    out.println("\n");
    out.println("   public void popUpWindow(String wndLabel) throws Exception {");
    out.println("      driver.findElement(By.linkText(wndLabel)).click();");
    out.println("      Thread.sleep(8000);");
    out.println("      String windowTitle= getCurrentWindowTitle();");
    out.println("      Thread.sleep(1000);");
    out.println("      String mainWindow = getMainWindowHandle(driver);");
    out.println("      Thread.sleep(1000);");
    out.println("      closeAllOtherWindows(mainWindow);");
    out.println("   }");
    out.println("");

    out.println("    public String getPopupWindowBodyText(WebDriver driver) {");
    out.println("      String parentWindowHandler = driver.getWindowHandle();");
    out.println("      String subWindowHandler = null;");
    out.println("      Set<String> handles = driver.getWindowHandles();");
    out.println("      Iterator<String> iterator = handles.iterator();");
    out.println("      while (iterator.hasNext()){");
    out.println("         subWindowHandler = iterator.next();");
    out.println("      }");
    out.println("      driver.switchTo().window(subWindowHandler);");
    out.println("      Thread.sleep(4000);");
    out.println("      String bodyText = driver.findElement(By.tagName(\"body\")).getText();");
    out.println("      driver.switchTo().window(parentWindowHandler);");
    out.println("      return bodyText;");
    out.println("   }");
    out.println("");

    out.println("   public String getMainWindowHandle(WebDriver driver) {");
    out.println("      return driver.getWindowHandle();");
    out.println("   }");
    out.println("");
    out.println("   public String getCurrentWindowTitle() {");
    out.println("      String windowTitle = driver.getTitle();");
    out.println("      return windowTitle;");
    out.println("   }");
    out.println("");
    out.println("   public boolean closeAllOtherWindows(String openWindowHandle) {");
    out.println("      Set<String> allWindowHandles = driver.getWindowHandles();");
    out.println("      for (String currentWindowHandle : allWindowHandles) {");
    out.println("         if (!currentWindowHandle.equals(openWindowHandle)) {");
    out.println("            driver.switchTo().window(currentWindowHandle);");
    out.println("            driver.close();");
    out.println("         }");
    out.println("      }");
    out.println("");
    out.println("      driver.switchTo().window(openWindowHandle);");
    out.println("      if (driver.getWindowHandles().size() == 1)");
    out.println("         return true;");
    out.println("      else");
    out.println("         return false;");
    out.println("   }");
    out.println("");

    out.println("   public boolean containsText(String text) {");
    out.println("       try {");
    out.println("          if (driver.findElement(By.xpath(\"//*[contains(.,'\" + text + \"')]\")) != null) {");
    out.println("              return true;");
    out.println("          }");
    out.println("      } catch (Exception e) {");
    out.println("          return false;");
    out.println("       }");
    out.println("       return false;");
    out.println("   }");
    out.println("");

    out.println("    public void goBack() {");
    out.println("      driver.navigate().back();");
    out.println("   }");
    out.println("");

    out.println("   public void navigateTo(String url) {");
    out.println("      driver.get(url);");
    out.println("   }");
    out.println("");
    out.println("");
    out.println("    public void maximizeWindow() {");
    out.println("      driver.manage().window().maximize();");
    out.println("   }");
    out.println("");
}

From source file:eu.annocultor.tools.GeneratorOfXmlSchemaForConvertersDoclet.java

static void printRuleDocStart(ClassDoc constr, PrintWriter out) throws Exception {
    out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    out.println("<document xmlns=\"http://maven.apache.org/XDOC/2.0\"");
    out.println("  xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
    out.println(//from w w  w  .j a  v a  2s.c om
            "  xsi:schemaLocation=\"http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd\">");
    out.println();
    out.println("  <properties>");
    out.println("    <title>Rule " + constr.name() + "</title>");
    out.println("  </properties>");
    out.println("  <body>");
    out.println("  <h1 id=\"Rule " + constr.name() + "\">Rule <code>" + constr.name() + "</code></h1>");
    out.println();
    out.println("  <p>" + constr.commentText() + "</p>");
    out.println();
    out.flush();

}

From source file:com.jolbox.benchmark.BenchmarkLaunch.java

/**
 * @param title //from w w  w.j av a2 s.co  m
 * @param filename 
 * @param results 
 * @throws IOException 
 */
private static void plotBarGraph(String title, String filename, long[] results) throws IOException {
    String fname = System.getProperty("java.io.tmpdir") + File.separator + filename;
    PrintWriter out = new PrintWriter(new FileWriter(fname + ".txt"));

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (ConnectionPoolType poolType : ConnectionPoolType.values()) {
        dataset.setValue(results[poolType.ordinal()], "ms", poolType);
        out.println(results[poolType.ordinal()] + "," + poolType);
    }
    out.close();
    JFreeChart chart = ChartFactory.createBarChart(title, "Connection Pool", "Time (ms)", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    try {
        ChartUtilities.saveChartAsPNG(new File(fname), chart, 1024, 768);
        System.out.println("******* Saved chart to: " + fname);
    } catch (IOException e) {
        e.printStackTrace();
        System.err.println("Problem occurred creating chart.");
    }
}