List of usage examples for java.io PrintWriter print
public void print(Object obj)
From source file:com.day.cq.wcm.foundation.Sitemap.java
public void draw(Writer w) throws IOException { PrintWriter out = new PrintWriter(w); int previousLevel = -1; for (Link aLink : links) { if (aLink.getLevel() > previousLevel) out.print("<div class=\"linkcontainer\">"); else if (aLink.getLevel() < previousLevel) { for (int i = aLink.getLevel(); i < previousLevel; i++) out.print("</div>"); }/*from w w w . j ava2s. c om*/ out.printf("<div class=\"link\"><a href=\"%s.html\">%s</a></div>", StringEscapeUtils.escapeHtml4(aLink.getPath()), aLink.getTitle()); previousLevel = aLink.getLevel(); } for (int i = -1; i < previousLevel; i++) out.print("</div>"); }
From source file:com.rabidgremlin.legalbeagle.report.TsvReportWriter.java
public void generateReport(String output, Report report) throws Exception { log.info("Writing report to {}...", output); PrintWriter out = new PrintWriter(new File(output)); out.println("File\tStatus\tDescription\tLicense(s)\tError"); for (ReportItem reportItem : report.getReportItems()) { out.print(reportItem.getFile().getAbsolutePath()); out.print("\t"); out.print(reportItem.getReportItemStatus()); out.print("\t"); if (reportItem.getDescription() != null) { out.print(reportItem.getDescription()); }//from w ww .j a v a 2s .c o m out.print("\t"); out.print(StringUtils.join(reportItem.getLicenses(), "; ")); out.print("\t"); if (reportItem.getError() != null) { out.print(reportItem.getError()); } out.println(); } out.flush(); out.close(); }
From source file:es.itecban.deployment.executionmanager.web.view.ReportView.java
public void render(Map model, HttpServletRequest req, HttpServletResponse resp) throws Exception { PrintWriter out = resp.getWriter(); resp.setContentType("application/octet-stream"); ExecutionReportType report = (ExecutionReportType) model.get("report"); // report.getTechnicalExecutionReport(); out.print(report.getTechnicalExecutionReport()); out.flush();/*from ww w .j av a2 s . c o m*/ out.close(); }
From source file:HSqlManager.java
public static void getClusterSizes(Connection connection) throws ClassNotFoundException, SQLException, InstantiationException, IllegalAccessException, IOException { Connection db = connection;//from w w w . ja v a2s .c om db.setAutoCommit(false); Statement stat = db.createStatement(); PrintWriter unique = new PrintWriter(new File("clustercount.log")); ResultSet call = stat.executeQuery("Select DISTINCT Cluster From Primerdb.Primers;"); Set<String> clust = new HashSet<>(); while (call.next()) { clust.add(call.getString("Cluster")); } unique.print("Cluster\t"); unique.print("Phage Count\t"); unique.print("18bp Unique Count\t"); unique.print("22bp Unique Count\t"); unique.print("25bp Unique Count\n"); unique.flush(); for (String c : clust) { call = stat.executeQuery("Select * From Primerdb.Primers where Cluster = '" + c + "'" + "and Bp = " + Integer.toString(18) + "and CommonP = true and UniqueP = true;"); int count = 0; while (call.next()) { count++; } call = stat.executeQuery("Select * From Primerdb.Primers where Cluster = '" + c + "'" + "and Bp = " + Integer.toString(22) + "and CommonP = true and UniqueP = true;"); int count2 = 0; while (call.next()) { count2++; } call = stat.executeQuery("Select * From Primerdb.Primers where Cluster = '" + c + "'" + "and Bp = " + Integer.toString(25) + "and CommonP = true and UniqueP = true;"); int count3 = 0; while (call.next()) { count3++; } call = stat.executeQuery("Select * From Primerdb.Phages where Cluster = '" + c + "';"); int count4 = 0; while (call.next()) { count4++; } unique.print(c + "\t"); unique.print(count4 + "\t"); unique.print(count + "\t"); unique.print(count2 + "\t"); unique.print(count3 + "\n"); unique.flush(); } System.out.println("Meta recorded"); }
From source file:com.adito.vfs.webdav.methods.PROPFIND.java
private void process(PrintWriter out, String name, String value) { if (value == null) return;// ww w . j av a 2s . c o m out.print(" <D:"); out.print(name); out.print(">"); out.print(value); out.print("</D:"); out.print(name); out.println(">"); }
From source file:com.alibaba.webx.tutorial.app1.module.screen.simple.Download.java
public void execute(@Param("filename") String filename) throws Exception { // buffering???? brc.setBuffering(false);//w ww . j av a 2 s. c o m // headers?????us-ascii???? filename = defaultIfNull(trimToNull(filename), "image") + ".txt"; filename = "\"" + escapeURL(filename) + "\""; response.setHeader("Content-disposition", "attachment; filename=" + filename); // ??content type? // HTML?JSON?JavaScript?JPG?PDF?EXCEL response.setContentType("text/plain"); PrintWriter out = response.getWriter(); for (int i = 0; i < 100; i++) { out.flush(); // ??? for (int j = 0; j < 100000; j++) { out.print(i); } out.println(); Thread.sleep(100); // ?? } }
From source file:com.taobao.lottery.web.app1.module.screen.simple.Download.java
public void execute(@Param("filename") String filename) throws Exception { // ,buffering,?,??? brc.setBuffering(false);/*from w w w. j av a 2 s . c om*/ // headers,?????us-ascii,???? filename = defaultIfNull(trimToNull(filename), "image") + ".txt"; filename = "\"" + escapeURL(filename) + "\""; response.setHeader("Content-disposition", "attachment; filename=" + filename); // ??content type,? // HTML?JSON?JavaScript?JPG?PDF?EXCEL response.setContentType("text/plain"); PrintWriter out = response.getWriter(); for (int i = 0; i < 100; i++) { out.flush(); // ??? for (int j = 0; j < 100000; j++) { out.print(i); } out.println(); Thread.sleep(100); // ?,? } }
From source file:com.mycompany.TFolderResource.java
@Override public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType) throws IOException, NotAuthorizedException, BadRequestException, MalformedURLException { // HEY EVERYONE // This is just a really simple dumb example of generating content - // you CAN use JSPs and templates and stuff!! PrintWriter pw = new PrintWriter(out); pw.print("<html><body>"); pw.print("<h1>" + this.getName() + "</h1>"); Request req = HttpManager.request(); pw.print("<p>" + this.getClass().getCanonicalName() + "</p>"); CalDavPrincipal curUser = null;//from www. j av a 2 s.co m if (HttpManager.request().getAuthorization() != null) { curUser = (CalDavPrincipal) HttpManager.request().getAuthorization().getTag(); } if (curUser == null) { generateOAuthLoginLinks(pw); } else { pw.print("<h2>Logged in as: " + curUser.getName() + "</h2>"); } doBody(pw); pw.print("</body>"); pw.print("</html>"); pw.flush(); }
From source file:com.alibaba.webx.study.app1.module.screen.simple.Download.java
public void execute(@Param("filename") String filename) throws Exception { // buffering???? brc.setBuffering(false);/*from w w w . j a v a 2 s . c o m*/ response.reset(); // headers?????us-ascii???? filename = defaultIfNull(trimToNull(filename), "image") + ".txt"; filename = "\"" + escapeURL(filename) + "\""; response.setHeader("Content-disposition", "attachment; filename=" + filename); // ??content type? // HTML?JSON?JavaScript?JPG?PDF?EXCEL response.setContentType("text/plain"); PrintWriter out = response.getWriter(); for (int i = 0; i < 100; i++) { out.flush(); // ??? for (int j = 0; j < 100000; j++) { out.print(i); } out.println(); Thread.sleep(100); // ?? } }
From source file:com.grantedbyme.example.ServletCallback.java
public void doProcess(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("application/json; charset=UTF-8"); // setup default response HashMap<String, Object> resultHashMap = new HashMap<>(); resultHashMap.put("success", false); resultHashMap.put("error", 0); JSONObject result = null;//from ww w . j a va2s.com // get request parameters String reqSignature = request.getParameter("signature"); String reqPayload = request.getParameter("payload"); String reqMessage = request.getParameter("message"); // process request if (reqSignature != null && reqPayload != null) { // read private key String privateKey = null; InputStream privateKeyInputStream = getClass().getResourceAsStream("/private_key.pem"); try { privateKey = IOUtils.toString(privateKeyInputStream); } finally { privateKeyInputStream.close(); } // read server key String serverKey = null; InputStream serverKeyInputStream = getClass().getResourceAsStream("/server_key.pem"); try { serverKey = IOUtils.toString(serverKeyInputStream); } finally { serverKeyInputStream.close(); } // _log(serverKey); // initialize BouncyCastle security provider Security.insertProviderAt(new org.bouncycastle.jce.provider.BouncyCastleProvider(), 0); // decrypt request HashMap<String, Object> params = new HashMap<>(); params.put("signature", reqSignature); params.put("payload", reqPayload); params.put("message", reqMessage); /*System.out.println("Signature: " + reqSignature); System.out.println("Payload: " + reqPayload); System.out.println("Message: " + reqMessage);*/ JSONObject requestJSON = CryptoUtil.decryptAndVerify(new JSONObject(params), serverKey, privateKey); if (requestJSON != null) { _log(requestJSON.toJSONString()); if (requestJSON.containsKey("operation")) { String operation = (String) requestJSON.get("operation"); if (operation.equals("ping")) { resultHashMap.put("success", true); } else if (operation.equals("unlink_account")) { if (requestJSON.containsKey("authenticator_secret_hash")) { // TODO: implement } resultHashMap.put("success", false); } else if (operation.equals("rekey_account")) { if (requestJSON.containsKey("authenticator_secret_hash")) { // TODO: implement } resultHashMap.put("success", false); } else if (operation.equals("revoke_challenge")) { if (requestJSON.containsKey("challenge")) { // TODO: implement } resultHashMap.put("success", false); } else { // operation not handled } } } result = CryptoUtil.encryptAndSign(new JSONObject(resultHashMap), serverKey, privateKey); } // write out response PrintWriter out = response.getWriter(); if (result != null) { out.print(result.toJSONString()); } else { out.print(new JSONObject(resultHashMap).toJSONString()); } out.close(); }