Example usage for java.io PrintWriter println

List of usage examples for java.io PrintWriter println

Introduction

In this page you can find the example usage for java.io PrintWriter println.

Prototype

public void println(Object x) 

Source Link

Document

Prints an Object and then terminates the line.

Usage

From source file:com.ebay.pulsar.analytics.security.spring.PlainTextBasicAuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException authException) throws IOException, ServletException {
    response.addHeader("WWW-Authenticate", "Basic realm=\"" + getRealmName() + "\"");
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    PrintWriter writer = response.getWriter();
    writer.println("HTTP Status " + HttpServletResponse.SC_UNAUTHORIZED + " - " + authException.getMessage());

}

From source file:Core.Security.CustomEntryPoint.java

public void commence(final HttpServletRequest request, final HttpServletResponse response,
        final AuthenticationException authException) throws IOException, ServletException {
    //Authentication failed, send error response.
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    response.addHeader("WWW-Authenticate", "Basic realm=" + getRealmName() + "");
    PrintWriter writer = response.getWriter();
    writer.println("HTTP Status 401 : " + authException.getMessage());
}

From source file:com.counter.counter.api.AuthenticationEntryPoint.java

@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authEx)
        throws IOException, ServletException {
    response.addHeader("WWW-Authenticate", "Basic realm=" + getRealmName());
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    PrintWriter writer = response.getWriter();
    writer.println("HTTP Status 401 - " + authEx.getMessage());
}

From source file:MyServlet.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    out.println("<HTML>");
    out.println("<HEAD>");
    out.println("<TITLE>");
    out.println("Using the init Method");
    out.println("</TITLE>");
    out.println("</HEAD>");
    out.println("<BODY>");
    out.println("<H1>Using the init Method</H1>");
    out.println(msg);/* ww  w.j a  v  a2  s.  c om*/
    out.println("</BODY>");
    out.println("</HTML>");
}

From source file:MainServlets.java

public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();
    count++;/*from w w  w  .jav  a  2  s. co m*/
    out.println("Since loading (and with a possible initialization");
    out.println("parameter figured in), this servlet has been accessed");
    out.println(count + " times.");
}

From source file:com.alibaba.webx.tutorial.app1.module.screen.simple.SayHi.java

public void execute() throws Exception {
    // content type??charsetcharset
    response.setContentType("text/plain");

    // ?servlet??
    PrintWriter out = response.getWriter();

    out.println("Hi there, how are you doing today?");
}

From source file:com.taobao.lottery.web.app1.module.screen.simple.SayHi.java

public void execute() throws Exception {
    // content type,??charsetcharset
    response.setContentType("text/plain");

    // ?servlet??
    PrintWriter out = response.getWriter();

    out.println("Hi there, how are you doing today?");
}

From source file:com.hp.test.framework.Reporting.Utlis.java

public static void create_tempfile(File SourceFile, File TempFile, String passed_count, String failed_count,
        String skipped_count, String graphType) {
    try {/*ww w . j av  a2  s .c om*/
        InputStream ips = new FileInputStream(SourceFile);
        InputStreamReader ipsr = new InputStreamReader(ips);
        BufferedReader br = new BufferedReader(ipsr);

        FileWriter fw = new FileWriter(TempFile);
        BufferedWriter bw = new BufferedWriter(fw);
        PrintWriter fileOut = new PrintWriter(bw);
        //        fileOut.println (string+"\n test of read and write !!"); 
        //  fileOut.close();

        String line;
        String variable = "s";
        if (graphType.equals("line")) {
            variable = "line";

        }
        //ArrayList<String> ar = new ArrayList<String>();
        int i = 0;
        while ((line = br.readLine()) != null) {

            if (i == 0) {
                fileOut.println(line);
                i = i + 1;
                continue;

            }
            if (line.contains("var " + variable)) {
                i = i + 1;

                String[] tem_ar = line.split("=");

                String variable1 = "var " + variable + "1 = [" + passed_count + "];";
                String variable2 = "var " + variable + "2 = [" + failed_count + "];";
                String variable3 = "var " + variable + "3 = [" + skipped_count + "];";
                if (i == 2) {
                    fileOut.println(variable1);
                    fileOut.println(variable2);
                    fileOut.println(variable3);
                }
                // string += line + "\n";
                // Run_counts.put(runs.get(count).toString(), ar);

            } else {
                fileOut.println(line);
            }
        }

        fileOut.close();
        br.close();
        log.info("Temp file after replacing counts created successfully--> " + TempFile.getPath());
    } catch (Exception e) {
        log.error(e.toString());

    }
}

From source file:MainClass.java

public void doGet(HttpServletRequest req, HttpServletResponse res)
        throws ServletException, java.io.IOException {

    res.setContentType("text/html");
    java.io.PrintWriter out = res.getWriter();
    out.println("<HTML>");
    out.println("<HEAD><TITLE>User Example</TITLE></HEAD>");
    out.println("<BODY>");

    String username = req.getRemoteUser();
    if (username == null) {
        out.println("Hello. You are not logged in.");
    } else if ("Bob".equals(username)) {
        out.println("Hello, Bob. Nice to see you again.");
    } else {// w  ww  . j ava  2s .  c  om
        out.println("Hello, " + username + ".");
    }
    out.println("</BODY>");
    out.println("</HTML>");
    out.close();
}

From source file:Utilitarios.Imprimir.java

public void imprimirGrafico(Image image) throws IOException {

    FileWriter arq = new FileWriter("D:\\Orcamentos\\Grafico.doc");//cria o arquivo
    PrintWriter gravarArq = new PrintWriter(arq);

    gravarArq.println("Oramento Banzos Instituto de Msica "); //linha de conteudo do txt
    gravarArq.println(" ");
    gravarArq.println(image);/*from   w  ww  . ja va2 s  . c o  m*/

    arq.close();

}