List of usage examples for java.io PrintStream println
public void println(Object x)
From source file:com.karpenstein.signalmon.NetConnHandler.java
@Override public void run() { server.addListener(this); String line;//from w w w. j a v a 2 s. c o m try { Log.d("NetConnHandler", "about to create input and output streams"); // Get input from the client DataInputStream in = new DataInputStream(sock.getInputStream()); PrintStream out = new PrintStream(sock.getOutputStream()); Log.d("NetConnHandler", "about to start looping"); while ((line = in.readLine()) != null && line.equals("G")) { if (stateChanged) { stateChanged = false; out.println(state.toString()); } else out.println(nullObj); } sock.close(); } catch (IOException ioe) { Log.e("SignalMonitor.NetConnHandler", "IOException on socket r/w: " + ioe, ioe); } }
From source file:cz.zcu.kiv.eegdatabase.logic.csv.SimpleCSVFactory.java
/** * Generating csv file from experiments/*from w w w . j a v a2s. co m*/ * * @return csv file with experiments * @throws IOException - error writing to stream */ @Transactional(readOnly = true) public OutputStream generateExperimentsCsvFile() throws IOException { log.debug("Generating csv file from experiments"); log.debug("Creating output stream"); String usedHardware = ""; OutputStream out = new ByteArrayOutputStream(); PrintStream printStream = new PrintStream(out); log.debug("Loading all experiments"); List<Experiment> experimentList = experimentDao.getAllRecords(); log.debug("Creating table header"); printStream.println(CSVUtils.EXPERIMENT_SUBJECT + CSVUtils.SEMICOLON + CSVUtils.EXPERIMENT_GENDER + CSVUtils.SEMICOLON + CSVUtils.EXPERIMENT_YEAR_OF_BIRTH + CSVUtils.SEMICOLON + CSVUtils.SCENARIO_TITLE + CSVUtils.SEMICOLON + CSVUtils.EXPERIMENT_USED_HARDWARE + CSVUtils.SEMICOLON + CSVUtils.EXPERIMENT_DETAILS); log.debug("Printing experiments to outputstream"); for (int i = 0; i < experimentList.size(); i++) { usedHardware = getHardware(experimentList.get(i).getHardwares()); printStream.println(CSVUtils.EEGBASE_SUBJECT_PERSON + experimentList.get(i).getPersonBySubjectPersonId().getPersonId() + CSVUtils.SEMICOLON + experimentList.get(i).getPersonBySubjectPersonId().getGender() + CSVUtils.SEMICOLON + getDateOfBirth(experimentList.get(i).getPersonBySubjectPersonId().getDateOfBirth()) + CSVUtils.SEMICOLON + experimentList.get(i).getScenario().getTitle() + CSVUtils.SEMICOLON + usedHardware + CSVUtils.SEMICOLON + CSVUtils.PROTOCOL_HTTP + domain + CSVUtils.EXPERIMENT_URL + experimentList.get(i).getExperimentId()); } log.debug("Close printing stream"); printStream.close(); return out; }
From source file:com.blackducksoftware.tools.nrt.generator.NRTReportGenerator.java
private void writeOutFilePaths(String compKey, PrintStream outputTextFile) { if (nrtConfig.isShowFilePaths()) { try {//from w w w. j a v a 2 s . c om outputTextFile.println("file paths (" + (componentMap.get(compKey).getPaths() != null ? componentMap.get(compKey).getPaths().size() : "0") + ")"); Set<String> paths = componentMap.get(compKey).getPaths(); if (paths != null) { for (String path : componentMap.get(compKey).getPaths()) { outputTextFile.println(path); } } else { log.info("No paths available for component key: " + compKey); } } // try catch (Exception e) { log.error("Unable to write out file paths", e); } } else { log.debug("Skipping paths section, set to false"); } }
From source file:net.lightbody.bmp.proxy.jetty.http.HashUserRealm.java
public void dump(PrintStream out) { out.println(this + ":"); out.println(super.toString()); out.println(_roles);//from w w w . j av a 2s. c o m }
From source file:com.leavesfly.lia.advsearching.SortingExample.java
public void displayResults(Query query, Sort sort) // #1 throws IOException { IndexSearcher searcher = new IndexSearcher(directory); searcher.setDefaultFieldSortScoring(true, false); // #2 TopDocs results = searcher.search(query, null, // #3 20, sort); // #3 System.out.println("\nResults for: " + // #4 query.toString() + " sorted by " + sort); System.out.println(StringUtils.rightPad("Title", 30) + StringUtils.rightPad("pubmonth", 10) + StringUtils.center("id", 4) + StringUtils.center("score", 15)); PrintStream out = new PrintStream(System.out, true, "UTF-8"); // #5 DecimalFormat scoreFormatter = new DecimalFormat("0.######"); for (ScoreDoc sd : results.scoreDocs) { int docID = sd.doc; float score = sd.score; Document doc = searcher.doc(docID); out.println(StringUtils.rightPad( // #6 StringUtils.abbreviate(doc.get("title"), 29), 30) + // #6 StringUtils.rightPad(doc.get("pubmonth"), 10) + // #6 StringUtils.center("" + docID, 4) + // #6 StringUtils.leftPad( // #6 scoreFormatter.format(score), 12)); // #6 out.println(" " + doc.get("category")); // out.println(searcher.explain(query, docID)); // #7 }//from w ww . j a v a 2 s.c om searcher.close(); }
From source file:aos.lucene.search.advanced.SortingExample.java
public void displayResults(Query query, Sort sort) // throws IOException { IndexSearcher searcher = new IndexSearcher(directory); searcher.setDefaultFieldSortScoring(true, false); // TopDocs results = searcher.search(query, null, // 20, sort); // LOGGER.info("\nResults for: " + // query.toString() + " sorted by " + sort); LOGGER.info(StringUtils.rightPad("Title", 30) + StringUtils.rightPad("pubmonth", 10) + StringUtils.center("id", 4) + StringUtils.center("score", 15)); PrintStream out = new PrintStream(System.out, true, "UTF-8"); // DecimalFormat scoreFormatter = new DecimalFormat("0.######"); for (ScoreDoc sd : results.scoreDocs) { int docID = sd.doc; float score = sd.score; Document doc = searcher.doc(docID); out.println(StringUtils.rightPad( // StringUtils.abbreviate(doc.get("title"), 29), 30) + // StringUtils.rightPad(doc.get("pubmonth"), 10) + // StringUtils.center("" + docID, 4) + // StringUtils.leftPad( // scoreFormatter.format(score), 12)); // out.println(" " + doc.get("category")); //out.println(searcher.explain(query, docID)); // }/*w w w . j a v a2s . c o m*/ searcher.close(); }
From source file:com.linkedin.bowser.tool.REPLServer.java
@Override public void messageReceived(IoSession session, Object message) throws Exception { final String line = message.toString(); if (line.trim().equalsIgnoreCase("quit")) { session.close();/*from ww w .j a va 2 s . c o m*/ return; } REPL repl = (REPL) session.getAttribute(REPL.class.getName()); if (repl != null) { ByteArrayOutputStream ous = new ByteArrayOutputStream(); PrintStream out = new PrintStream(ous); try { repl.execute(line, new PrintStream(ous)); } catch (QueryRuntimeException e) { out.println(e.getMessage()); } catch (QueryFormatException e) { out.println(e.getMessage()); } out.flush(); session.write(ous.toString()); } }
From source file:net.praqma.jenkins.plugin.prqa.PRQARemoteReport.java
@Override public PRQAComplianceStatus invoke(File f, VirtualChannel channel) throws IOException, InterruptedException { try {//from w w w.j av a2 s . co m Map<String, String> expandedEnvironment = expandEnvironment(report.getEnvironment(), report.getAppSettings(), report.getSettings()); report.setEnvironment(expandedEnvironment); report.setWorkspace(f); PrintStream log = listener.getLogger(); boolean reportBasedOnSettingFile = StringUtils.isBlank(report.getSettings().projectFile) && StringUtils.isBlank(report.getSettings().fileList); if (!reportBasedOnSettingFile) { log.println("Analysis command:"); log.println(report.createAnalysisCommand(isUnix)); log.println(report.analyze(isUnix).stdoutBuffer); } FilePath workspacePath = new FilePath(f); for (PRQAContext.QARReportType type : report.getSettings().chosenReportTypes) { String pattern = "**/" + PRQAReport.getNamingTemplate(type, PRQAReport.XHTML_REPORT_EXTENSION); for (FilePath file : workspacePath.list(pattern)) { log.println("Deleting " + file.getName()); file.delete(); } } log.println("Report command:"); log.println(report.createReportCommand(isUnix)); log.println(report.report(isUnix).stdoutBuffer); String uploadCommand = report.createUploadCommand(); if (StringUtils.isNotBlank(uploadCommand)) { log.println("Uploading with command:"); log.println(uploadCommand); log.println(report.upload().stdoutBuffer); } return report.getComplianceStatus(); } catch (PrqaException exception) { throw new IOException(exception.getMessage(), exception); } }
From source file:io.appium.java_client.service.local.AppiumServiceBuilder.java
@Override protected File findDefaultExecutable() { validateNodeJSVersion();/*from ww w. j a v a 2 s . co m*/ Runtime rt = Runtime.getRuntime(); Process p; try { p = rt.exec(NODE_COMMAND_PREFIX + " node"); } catch (IOException e) { throw new RuntimeException(e); } try { OutputStream outputStream = p.getOutputStream(); PrintStream out = new PrintStream(outputStream); out.println("console.log(process.execPath);"); out.close(); return new File(getProcessOutput(p.getInputStream())); } catch (Throwable t) { throw new RuntimeException(t); } finally { p.destroy(); } }
From source file:htsjdk.samtools.tabix.IndexingFeatureWriterNGTest.java
@Test public void blockCompressFile() throws FileNotFoundException { String file = "/home/sol/Downloads/test.chain.gff"; String out = "/home/sol/Downloads/t.bgz"; BlockCompressedOutputStream bcos = new BlockCompressedOutputStream(new File(out)); PrintStream ps = new PrintStream(bcos); Scanner scan = new Scanner(new File(file)); while (scan.hasNext()) { ps.println(scan.nextLine()); }// www . j av a2s . c om ps.close(); }