Best code examples for Java 8 PrintWriter class (java.io.PrintWriter)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PrintWriter class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 PrintWriter examples from Open Source projects
This code example shows how to use the following methods: close, print, println
    public void contribute(Dump dump) throws DumpContributionFailedException {
        ClusterState clusterState = clusterService.state();
        DiscoveryNodes nodes = clusterState.nodes();
        RoutingTable routingTable = clusterState.routingTable();
 
        PrintWriter writer = new PrintWriter(dump.createFileWriter("cluster.txt"));
 
        writer.println("===== CLUSTER NODES ======");
        writer.print(nodes.prettyPrint());
 
        writer.println("===== ROUTING TABLE ======");
        writer.print(routingTable.prettyPrint());
 
        writer.close();
    } 
} 
Full Snippet Info
10
CodeRank
This code example shows how to use the following methods: close, println
 
        LayeredTestModule module = new LayeredTestModule();
 
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<html>");
        out.println("<head><title>LayeredTestServlet</title></head>");
        out.println("<body>Done</body>");
        out.println("</html>");
        out.close();
    } 
 
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException { 
        processRequest(request, response);
    } 
 
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException { 
        processRequest(request, response);
Full Snippet Info
9
CodeRank
This code example shows how to use the following methods: close, flush, println
    return conf;
  } 
 
  private void writeNodeHealthScriptFile(String scriptStr, boolean setExecutable)
      throws IOException { 
    PrintWriter pw = new PrintWriter(new FileOutputStream(nodeHealthscriptFile));
    pw.println(scriptStr);
    pw.flush();
    pw.close();
    FileUtil.setExecutable(nodeHealthscriptFile, setExecutable);
  } 
 
  @Test 
  public void testNodeHealthScriptShouldRun() throws IOException { 
    // Node health script should not start if there is no property called 
    // node health script path. 
    Assert.assertFalse("By default Health script should not have started",
        NodeHealthScriptRunner.shouldRun(new Configuration()));
    Configuration conf = getConfForNodeHealthScript();
    // Node health script should not start if the node health script does not 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: close, print
        } 
        InitialContext ctx = new InitialContext();
        Object obj = null;
        try { 
            obj = ctx.lookup(name);
            out.print(obj.getClass().getName());
        } catch (NameNotFoundException nnfe) {
            out.print(NOT_FOUND);
        } 
        out.close();
    } 
 
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException { 
        try { 
            processRequest(request, response);
        } catch (NamingException ne) {
            throw new ServletException(ne);
        } 
    } 
Full Snippet Info
8
CodeRank
This code example shows how to use the following methods: close
  { 
    final String TEST_STRING = "Entity body should not be contained in RestException.toString()";
    RestResponse response = new RestResponseBuilder().setEntity(ByteString.copyString(TEST_STRING, "UTF-8")).build();
    RestException e = new RestException(response);
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    pw.close();
    Assert.assertEquals(sw.toString().indexOf(TEST_STRING), -1, TEST_STRING);
  } 
} 
Full Snippet Info
8
CodeRank
Related Java 8 PrintWriter Questions & Answers:
See Code Examples for Java 8 PrintWriter Methods: