List of usage examples for java.io PrintStream print
public void print(Object obj)
From source file:org.isatools.isacreator.io.exportisa.ISAFileOutput.java
protected void printStudy(PrintStream investigationFilePrintStream, Study study) { DataEntryForm def = ApplicationManager.getUserInterfaceForISASection(study); boolean doNotUpdateGUIBeforeSave = Boolean .parseBoolean(ISAcreatorProperties.getProperty("DO_NOT_UPDATE_FROM_GUI")); System.out.println("Do Not Update GUI before save? " + doNotUpdateGUIBeforeSave); if (def != null && !doNotUpdateGUIBeforeSave) { System.out.println("UPDATING FROM GUI..."); def.update();//from w w w .j av a 2s.c o m } investigationFilePrintStream.print( ISASectionExportAdaptor.exportISASectionAsString(study, InvestigationFileSection.STUDY_SECTION)); investigationFilePrintStream.print(ISASectionExportAdaptor.exportISASectionAsString(study.getStudyDesigns(), InvestigationFileSection.STUDY_DESIGN_SECTION)); investigationFilePrintStream.print(ISASectionExportAdaptor.exportISASectionAsString(study.getPublications(), InvestigationFileSection.STUDY_PUBLICATIONS)); investigationFilePrintStream.print(ISASectionExportAdaptor.exportISASectionAsString(study.getFactors(), InvestigationFileSection.STUDY_FACTORS)); investigationFilePrintStream.print(ISASectionExportAdaptor.exportISASectionAsString(getAssaysAsList(study), InvestigationFileSection.STUDY_ASSAYS)); investigationFilePrintStream.print(ISASectionExportAdaptor.exportISASectionAsString(study.getProtocols(), InvestigationFileSection.STUDY_PROTOCOLS)); investigationFilePrintStream.print(ISASectionExportAdaptor.exportISASectionAsString(study.getContacts(), InvestigationFileSection.STUDY_CONTACTS)); }
From source file:org.apache.hadoop.hive.metastore.tools.BenchmarkTool.java
@Override public void run() { LOG.info("Using warmup " + warmup + " spin " + spinCount + " nparams " + nParameters + " threads " + nThreads);/* w w w.ja va2 s .c o m*/ StringBuilder sb = new StringBuilder(); BenchData bData = new BenchData(dbName, tableName); MicroBenchmark bench = new MicroBenchmark(warmup, spinCount); BenchmarkSuite suite = new BenchmarkSuite(); suite.setScale(scale).doSanitize(doSanitize).add("getNid", () -> benchmarkGetNotificationId(bench, bData)) .add("listDatabases", () -> benchmarkListDatabases(bench, bData)) .add("listTables", () -> benchmarkListAllTables(bench, bData)) .add("getTable", () -> benchmarkGetTable(bench, bData)) .add("createTable", () -> benchmarkTableCreate(bench, bData)) .add("dropTable", () -> benchmarkDeleteCreate(bench, bData)) .add("dropTableWithPartitions", () -> benchmarkDeleteWithPartitions(bench, bData, 1, nParameters)) .add("addPartition", () -> benchmarkCreatePartition(bench, bData)) .add("dropPartition", () -> benchmarkDropPartition(bench, bData)) .add("listPartition", () -> benchmarkListPartition(bench, bData)) .add("getPartition", () -> benchmarkGetPartitions(bench, bData, 1)) .add("getPartitionNames", () -> benchmarkGetPartitionNames(bench, bData, 1)) .add("getPartitionsByNames", () -> benchmarkGetPartitionsByName(bench, bData, 1)) .add("renameTable", () -> benchmarkRenameTable(bench, bData, 1)) .add("dropDatabase", () -> benchmarkDropDatabase(bench, bData, 1)); for (int howMany : instances) { suite.add("listTables" + '.' + howMany, () -> benchmarkListTables(bench, bData, howMany)) .add("dropTableWithPartitions" + '.' + howMany, () -> benchmarkDeleteWithPartitions(bench, bData, howMany, nParameters)) .add("listPartitions" + '.' + howMany, () -> benchmarkListManyPartitions(bench, bData, howMany)) .add("getPartitions" + '.' + howMany, () -> benchmarkGetPartitions(bench, bData, howMany)) .add("getPartitionNames" + '.' + howMany, () -> benchmarkGetPartitionNames(bench, bData, howMany)) .add("getPartitionsByNames" + '.' + howMany, () -> benchmarkGetPartitionsByName(bench, bData, howMany)) .add("addPartitions" + '.' + howMany, () -> benchmarkCreatePartitions(bench, bData, howMany)) .add("dropPartitions" + '.' + howMany, () -> benchmarkDropPartitions(bench, bData, howMany)) .add("renameTable" + '.' + howMany, () -> benchmarkRenameTable(bench, bData, howMany)) .add("dropDatabase" + '.' + howMany, () -> benchmarkDropDatabase(bench, bData, howMany)); } if (doList) { suite.listMatching(matches, exclude).forEach(System.out::println); return; } LOG.info("Using table '{}.{}", dbName, tableName); try (HMSClient client = new HMSClient(getServerUri(host, String.valueOf(port)), confDir)) { bData.setClient(client); if (!client.dbExists(dbName)) { client.createDatabase(dbName); } if (client.tableExists(dbName, tableName)) { client.dropTable(dbName, tableName); } // Arrange various benchmarks in a suite BenchmarkSuite result = suite.runMatching(matches, exclude); Formatter fmt = new Formatter(sb); if (doCSV) { result.displayCSV(fmt, csvSeparator); } else { result.display(fmt); } PrintStream output = System.out; if (outputFile != null) { output = new PrintStream(outputFile); } if (outputFile != null) { // Print results to stdout as well StringBuilder s = new StringBuilder(); Formatter f = new Formatter(s); result.display(f); System.out.print(s); f.close(); } output.print(sb.toString()); fmt.close(); if (dataSaveDir != null) { saveData(result.getResult(), dataSaveDir, scale); } } catch (Exception e) { e.printStackTrace(); } }
From source file:dk.hippogrif.prettyxml.app.Main.java
private static void help(PrintStream ps) { ps.println("prettyxml prettyprints an xml file"); ps.println(""); usage(ps);//from w w w. j a va 2 s . co m ps.println(""); ps.println("the property file may hold the following properties:"); ps.println(" encoding = string, e.g., UTF-8 (default), ISO-8859-1"); ps.println(" expandEmptyElements = TRUE | FALSE (default)"); ps.println(" indent = no of spaces to indent (min 1, max 99)"); ps.println(" lineSeparator = string, i.e., \\r, \\n or \\r\\n (default)"); ps.println(" omitDeclaration = TRUE | FALSE (default)"); ps.println(" omitEncoding = TRUE | FALSE (default)"); ps.println(" textMode = NORMALIZE | TRIM | TRIM_FULL_WHITE | PRESERVE (default)"); ps.println(" indentAttributes = TRUE | FALSE (default)"); ps.println(" sortAttributes = TRUE | FALSE (default)"); ps.println(" transform = an xslt pipeline of one or more stylesheets separated by ;"); ps.println(" input = input file"); ps.println(" url = input url"); ps.println(" output = output file"); ps.println(""); ps.println("use the xslt pipeline to sort elements or filter nodes"); ps.println("standard input is used if no file or url is specified"); ps.println("standard output is used if no file is specified"); ps.println("property file and transformation stylesheets are located in this order:"); ps.println(" built-in, file, classpath resource"); ps.print("built-in property files:"); String[] sa = PrettyPrint.getSettings(); for (int i = 0; i < sa.length; i++) { ps.print(" " + sa[i]); } ps.println(""); ps.print("built-in transformation stylesheets:"); sa = PrettyPrint.getTransformations(); for (int i = 0; i < sa.length; i++) { ps.print(" " + sa[i]); } ps.println(""); }
From source file:io.horizondb.model.core.fields.DecimalField.java
/** * {@inheritDoc}/*from ww w .j a va2 s. c om*/ */ @Override public void writePrettyPrint(PrintStream stream) { if (isNaN(this.mantissa, this.exponent)) { stream.print("NaN"); return; } if (isPositiveInfinity(this.mantissa, this.exponent)) { stream.print("Infinity"); return; } if (isNegativeInfinity(this.mantissa, this.exponent)) { stream.print("-Infinity"); return; } stream.print(this.mantissa); stream.print(" * 10E"); stream.print(this.exponent); }
From source file:com.protheos.graphstream.JSONSender.java
/** * Send JSONObject message to Gephi server * //from ww w. j a v a2 s . c o m * @param obj * , the JSON message content * @param operation * , the operation sending to the server, like "updateGraph", * "getGraph" */ private void doSend(JSONObject obj, String operation) { try { URL url = new URL("http", host, port, "/" + workspace + "?operation=" + operation + "&format=JSON"); URLConnection connection = url.openConnection(); connection.setDoOutput(true); connection.connect(); OutputStream outputStream = null; PrintStream out = null; try { outputStream = connection.getOutputStream(); out = new PrintStream(outputStream, true); out.print(obj.toString() + EOL); out.flush(); out.close(); // send event message to the server and read the result from the // server InputStream inputStream = connection.getInputStream(); BufferedReader bf = new BufferedReader(new InputStreamReader(inputStream)); String line; while ((line = bf.readLine()) != null) { // if (debug) debug(line); } inputStream.close(); } catch (UnknownServiceException e) { // protocol doesn't support output e.printStackTrace(); return; } } catch (IOException ex) { ex.printStackTrace(); } }
From source file:net.erdfelt.android.sdkfido.console.TablePrinter.java
public void print(PrintStream out) { String indent = " "; // Need to calculate widths int widths[] = new int[columnCount]; // Establish baseline values with headers row for (int col = 0; col < columnCount; col++) { widths[col] = headers[col].length(); }//from w w w.j a va2 s . co m // Now parse all of the rows to grow the column widths to fit. for (String[] row : rows) { for (int col = 0; col < columnCount; col++) { widths[col] = Math.max(row[col].length(), widths[col]); } } // Print Header Row out.print(indent); boolean delim = false; for (int col = 0; col < columnCount; col++) { if (delim) { out.print(" | "); } out.print(StringUtils.rightPad(headers[col], widths[col])); delim = true; } out.println(); // Print Horiz Rule out.print("--"); delim = false; for (int col = 0; col < columnCount; col++) { if (delim) { out.print("-+-"); } out.print(StringUtils.rightPad("", widths[col], '-')); delim = true; } out.println("--"); // Print Rows for (String[] row : rows) { out.print(indent); delim = false; for (int col = 0; col < columnCount; col++) { if (delim) { out.print(" | "); } out.print(StringUtils.rightPad(row[col], widths[col])); delim = true; } out.println(); } }
From source file:org.elacin.pdfextract.xml.SimpleXMLOutput.java
public void writeTree(@NotNull final DocumentNode root, @NotNull final File output) { /* write to file */ log.info("LOG00110:Opening " + output + " for output"); final PrintStream out; try {//from www . j av a 2 s. c o m out = new PrintStream(new BufferedOutputStream(new FileOutputStream(output, false), 8192 * 4), false, "UTF-8"); } catch (Exception e) { throw new RuntimeException("Could not open output file", e); } StringBuffer sb = new StringBuffer(); writeDocument(sb, root); // final String result = PrettyPrinter.prettyFormat(sb.toString()); final String result = sb.toString(); out.print(result); out.close(); }
From source file:org.apache.pig.piggybank.test.storage.TestXMLLoader.java
/** * This test checks that a multi-line tag spanning two splits should be * matched./* ww w . j av a 2s .com*/ * @throws Exception */ public void testXMLLoaderShouldMatchTagSpanningSplits() throws Exception { Configuration conf = new Configuration(); long blockSize = 512; conf.setLong("fs.local.block.size", blockSize); conf.setLong(MRConfiguration.MAX_SPLIT_SIZE, blockSize); String tagName = "event"; File tempFile = File.createTempFile("long-file", ".xml"); FileSystem localFs = FileSystem.getLocal(conf); FSDataOutputStream directOut = localFs.create(new Path(tempFile.getAbsolutePath()), true); String matchingElement = "<event>\ndata\n</event>\n"; long pos = 0; int matchingCount = 0; PrintStream ps = new PrintStream(directOut); // 1- Write some elements that fit completely in the first block while (pos + 2 * matchingElement.length() < blockSize) { ps.print(matchingElement); pos += matchingElement.length(); matchingCount++; } // 2- Write a long element that spans multiple lines and multiple blocks String longElement = matchingElement.replace("data", "data\ndata\ndata\ndata\ndata\ndata\ndata\ndata\ndata\ndata\ndata\n"); ps.print(longElement); pos += longElement.length(); matchingCount++; // 3- Write some more elements to fill in the second block completely while (pos < 2 * blockSize) { ps.print(matchingElement); pos += matchingElement.length(); matchingCount++; } ps.close(); PigServer pig = new PigServer(LOCAL, conf); String tempFileName = tempFile.getAbsolutePath().replace("\\", "\\\\"); String query = "A = LOAD '" + tempFileName + "' USING org.apache.pig.piggybank.storage.XMLLoader('event') as (doc:chararray);"; pig.registerQuery(query); Iterator<?> it = pig.openIterator("A"); int count = 0; while (it.hasNext()) { Tuple tuple = (Tuple) it.next(); if (tuple == null) break; else { if (tuple.size() > 0) { count++; // Make sure the returned text is a proper XML element DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); Document doc = docBuilder.parse(new ByteArrayInputStream(((String) tuple.get(0)).getBytes())); assertTrue(doc.getDocumentElement().getNodeName().equals(tagName)); } } } assertEquals(matchingCount, count); }
From source file:com.google.cloud.dataflow.sdk.runners.worker.TextReaderTest.java
private void testStringPayload(String[] lines, String separator, boolean stripNewlines) throws Exception { File tmpFile = tmpFolder.newFile(); List<String> expected = new ArrayList<>(); PrintStream writer = new PrintStream(new FileOutputStream(tmpFile)); for (String line : lines) { writer.print(line); writer.print(separator);/*from w w w . ja v a 2s . co m*/ expected.add(stripNewlines ? line : line + separator); } writer.close(); TextReader<String> textReader = new TextReader<>(tmpFile.getPath(), stripNewlines, null, null, StringUtf8Coder.of(), TextIO.CompressionType.UNCOMPRESSED); List<String> actual = new ArrayList<>(); try (Reader.ReaderIterator<String> iterator = textReader.iterator()) { while (iterator.hasNext()) { actual.add(iterator.next()); } } assertEquals(expected, actual); }
From source file:org.hyperic.hq.autoinventory.ScanState.java
public void printMainStatus(PrintStream out) { out.print("\nOVERALL STATUS: "); String status = null;//from www. j ava2s. c o m if (_core.getIsInterrupted()) { status = "interrupted before normal completion"; } else if (_core.getIsDone()) { status = "completed"; } else { status = "scan in progress"; } if (_core.getGlobalException() != null) { status += ", however a general scanning error occurred"; } else if (hasExceptions()) { status += " successfully, however one or more scan methods had errors"; } else if (_core.getIsDone()) { status += " successfully with no errors"; } out.println(status); String duration = StringUtil.formatDuration(getScanDuration()); out.println("Run time: " + duration); AIPlatformValue platform = _core.getPlatform(); if (platform != null) { out.println("\nPlatform Detected:"); out.println("\t" + platform); out.println("\tIP addresses: " + StringUtil.arrayToString(platform.getAIIpValues())); } else { out.println("\nNo Platform Detected!"); } }