List of usage examples for java.io PrintWriter printf
public PrintWriter printf(String format, Object... args)
From source file:org.keycloak.testsuite.ApplicationServlet.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String title = ""; if (req.getRequestURI().endsWith("auth")) { title = "AUTH_RESPONSE"; } else if (req.getRequestURI().endsWith("logout")) { title = "LOGOUT_REQUEST"; } else {//from ww w. j av a 2 s. c o m title = "APP_REQUEST"; } PrintWriter pw = resp.getWriter(); pw.printf("<html><head><title>%s</title></head><body>", title); pw.printf(LINK, "http://localhost:8081/auth/rest/realms/test/account", "account", "account"); pw.print("</body></html>"); pw.flush(); }
From source file:it.tidalwave.northernwind.frontend.springmvc.SpringMvcResponseHolderTest.java
/******************************************************************************************************************* * * Note that here we are not testing the correctness of the actual output sent to the network: in fact, it's a * responsibility of Spring MVC. We are only testing the proper contents of ResponseEntity. * ******************************************************************************************************************/ @Override/*w w w . j a v a 2 s . c om*/ protected void assertContents(final @Nonnull ResponseBuilder<?> builder, final String fileName) throws Exception { final TestHelper.TestResource tr = helper.testResourceFor(fileName); final ByteArrayOutputStream baos = new ByteArrayOutputStream(); final ResponseEntity<byte[]> responseEntity = (ResponseEntity<byte[]>) builder.build(); final HttpHeaders headers = responseEntity.getHeaders(); final PrintWriter pw = new PrintWriter(baos); // FIXME: charset? pw.printf("HTTP/1.1 %d%n", responseEntity.getStatusCode().value()); headers.entrySet().stream().sorted(comparing(Entry::getKey)) .forEach(e -> pw.printf("%s: %s%n", e.getKey(), e.getValue().get(0))); pw.println(); pw.flush(); baos.write(responseEntity.getBody()); tr.writeToActualFile(baos.toByteArray()); tr.assertActualFileContentSameAsExpected(); }
From source file:org.kuali.kfs.sys.service.impl.ReportAggregatorServiceTextImpl.java
protected void prepareForNewFile(PrintWriter outputWriter) { // 12 represents the ASCII Form Feed character outputWriter.printf("%c" + newLineCharacter, 12); }
From source file:org.apache.flink.streaming.python.api.PythonStreamBinder.java
private void generateAndCopyPlanFile(String dstPath, String mainScriptFullPath) throws IOException { String moduleName = FilenameUtils.getBaseName(mainScriptFullPath); FileWriter fileWriter = new FileWriter( dstPath + File.separator + PythonEnvironmentConfig.FLINK_PYTHON_PLAN_NAME); PrintWriter printWriter = new PrintWriter(fileWriter); printWriter.printf("import %s\n\n", moduleName); printWriter.printf("%s.main()\n", moduleName); printWriter.close();//from w ww .jav a2 s .c om }
From source file:com.nridge.core.base.io.xml.RangeXML.java
public void saveNode(PrintWriter aPW, int anIndentAmount) throws IOException { IOXML.indentLine(aPW, anIndentAmount); aPW.printf("<%s", RANGE_NODE_NAME); }
From source file:org.bdval.tools.ScanParameters.java
private void runOnce(final String[] values) { final StringWriter writer = new StringWriter(); final PrintWriter pw = new PrintWriter(writer); pw.printf(arguments, (Object[]) values); pw.flush();//from w ww . ja v a 2s.co m final String args = writer.getBuffer().toString(); System.err.println("Arguments: " + arguments); System.out.println("Args list separated"); final List<String> runArgsList = new LinkedList<String>(); for (final String s : args.split(" ")) { if (StringUtils.isNotBlank(s)) { runArgsList.add(s); } } final String[] runArguments = runArgsList.toArray(new String[runArgsList.size()]); try { final Class<?> discoverAndValidateClass = Class.forName(toolClassName); final WithProcessMethod instance = (WithProcessMethod) discoverAndValidateClass.newInstance(); instance.process(runArguments); } catch (IllegalAccessException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (InstantiationException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (JSAPException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } catch (ClassNotFoundException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }
From source file:msec.org.FileUploadServlet.java
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Map<String, String> fields = new HashMap<String, String>(); List<String> fileNames = new ArrayList<String>(); request.setCharacterEncoding("UTF-8"); String result = FileUpload(fields, fileNames, request, response); response.setCharacterEncoding("UTF-8"); response.setContentType("text/html; charset=utf-8"); PrintWriter out = response.getWriter(); if (result == null || !result.equals("success")) { out.printf("{\"status\":100, \"message\":\"%s\"}", result == null ? "" : result); return;// ww w. j av a2s.c om } String handleClass = fields.get("handleClass"); if (handleClass != null && handleClass.equals("beans.service.LibraryFileUpload")) { //out.write(new LibraryFileUpload().run(fields, fileNames)); return; } if (handleClass != null && handleClass.equals("beans.service.SharedobjectUpload")) { // out.write(new SharedobjectUpload().run(fields, fileNames)); return; } out.write("{\"status\":100, \"message\":\"unkown handle class\"}"); return; }
From source file:com.buaa.cfs.conf.ReconfigurationServlet.java
private void printHeader(PrintWriter out, String nodeName) { out.print("<html><head>"); out.printf("<title>%s Reconfiguration Utility</title>%n", StringEscapeUtils.escapeHtml(nodeName)); out.print("</head><body>\n"); out.printf("<h1>%s Reconfiguration Utility</h1>%n", StringEscapeUtils.escapeHtml(nodeName)); }
From source file:de.tudarmstadt.ukp.experiments.argumentation.sequence.writers.HtmlWriter.java
private void printHeader(JCas aJCas, PrintWriter out) { WebArgumentMetadata webArgumentMetadata = JCasUtil.selectSingle(aJCas, WebArgumentMetadata.class); out.printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html PUBLIC" + " \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/" + "DTD/strict.dtd\">\n<html xmlns=\"http://www.w3.org/TR/xhtml1/strict\" >\n" + "<head>\n<title>%s</title>\n" + "<link rel=\"stylesheet\" href=\"style.css\"/>\n" + " <meta http-equiv=\"content-type\" content=\"application/xhtml+xml; charset=UTF-8\" />\n" + "</head>\n<body>\n", webArgumentMetadata.getOrigId()); out.printf("<h1>%s</h1>\n<h2>%s, %s</h2>\n", webArgumentMetadata.getOrigId(), webArgumentMetadata.getTopic(), webArgumentMetadata.getDocType()); }
From source file:com.nridge.core.base.io.xml.DataFieldXML.java
public void saveNode(PrintWriter aPW, int anIndentAmount) throws IOException { IOXML.indentLine(aPW, anIndentAmount); aPW.printf("<%s", IO.XML_FIELD_NODE_NAME); }