Example usage for java.io PrintWriter flush

List of usage examples for java.io PrintWriter flush

Introduction

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

Prototype

public void flush() 

Source Link

Document

Flushes the stream.

Usage

From source file:spring.DirectWriteController.java

@RequestMapping(value = "/write")
public void write(PrintWriter writer) {
    writer.println("OK");
    writer.flush();
}

From source file:com.javiermoreno.springboot.mvc.minimal.httpd.PingController.java

@RequestMapping(value = "/long", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)/*  ww w .ja va  2s. c o m*/
void longPing(HttpServletResponse response) throws IOException, InterruptedException {
    response.setBufferSize(0);
    PrintWriter out = response.getWriter();
    out.println();
    out.flush();
    for (int i = 0; i < 60 * 5; i++) {
        out.format("Current server time: %s.\r\n", new Date());
        out.flush();
        Thread.sleep(1000);
    }
}

From source file:sct.ApplicationContextNamespaceTestServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    XmlWebApplicationContext ctx = new XmlWebApplicationContext();
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    ctx.setClassLoader(loader);//from  www .  j a  va 2s. co m
    ctx.setConfigLocation("classpath:sct/namespace.xml");
    ctx.refresh();
    Object bean = ctx.getBean("someBean");
    if (bean != null) {
        PrintWriter writer = resp.getWriter();
        writer.write("OK");
        writer.flush();
    }
}

From source file:fi.helsinki.opintoni.security.AuthFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);

    PrintWriter writer = response.getWriter();
    writer.write(exception.getMessage());
    writer.flush();
}

From source file:eu.ensure.aging.AgingSimulator.java

/**
 * Write "help" to the provided OutputStream.
 */// w w w .  j a  v  a 2s  .c  om
public static void printHelp(final Options options, final OutputStream out) {

    HelpFormatter formatter = new HelpFormatter();
    PrintWriter pw = new PrintWriter(out);

    final int printedRowWidth = 80;
    final int spacesBeforeOption = 1;
    final int spacesBeforeOptionDescription = 3;

    String syntax = appName + " [options] <source> [<destination>]";

    String header = "\nAvailable options:";

    String footer = "\n" + "The options <arg> is either 'true' or 'false' and by default the -n option is\n"
            + "'true'.\n\n"
            + "<source> and optionally <destination> are paths to Archival Information Packages\n"
            + "(AIPs) and this utility is used to flip bits in AIPs, which are assumed to use\n"
            + "the TAR format, in order to simulate aging of stored AIPs.\n";

    formatter.printHelp(pw, printedRowWidth, syntax, header, options, spacesBeforeOption,
            spacesBeforeOptionDescription, footer, false);

    pw.flush();
}

From source file:net.chwise.websearch.Mol2SmilesServlet.java

@Override
public void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
    String mol = req.getParameter("mol");
    ToSmilesConverter converter = new ToSmilesConverter();
    String smiles = converter.convert(mol);
    JSONObject jsonDoc = new JSONObject();

    LOGGER.log(Level.INFO, "Molfile to convert: {0}", mol);

    try {//w w  w.  ja  v  a  2 s . c  o  m
        jsonDoc.put("smiles", smiles);
    } catch (JSONException e) {
        throw new RuntimeException("Exception in Mol2SmilesServlet", e);
    }

    resp.setContentType("application/json");
    PrintWriter out = resp.getWriter();
    out.print(jsonDoc);
    out.flush();
}

From source file:com.bitranger.parknshop.seller.controller.SellerApplyShopCtrl.java

@RequestMapping(value = "/seller/applyShop", method = RequestMethod.GET)
public void applyShop(HttpServletRequest request, HttpServletResponse response) throws IOException {

    PsSeller psSeller = (PsSeller) request.getSession().getAttribute("currentSeller");

    String message = request.getParameter("msg");

    PsShopApply psShopApply = new PsShopApply();
    psShopApply.setIdSeller(psSeller.getId());
    psShopApply.setMessage(message);//from  ww  w  .java  2s.  c o m
    psShopApply.setTimeCreated(new Timestamp(System.currentTimeMillis()));

    psShopApplyDAO.save(psShopApply);

    PrintWriter out = response.getWriter();
    out.write("success");
    out.flush();
    out.close();
}

From source file:com.sentinel.rest.handlers.AuthFailureHandler.java

@Override
public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response,
        AuthenticationException exception) throws IOException, ServletException {
    LOG.trace("Method: onAuthenticationFailure called.");

    response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
    PrintWriter writer = response.getWriter();
    writer.write(exception.getMessage());
    writer.flush();
    LOG.trace("Method: onAuthenticationFailure finished.");
}

From source file:LVCoref.MMAX2.java

public static void exportNeAnnotation(Document d, String export_filename) {
    PrintWriter out;
    try {/*  w w w .  ja  va2 s  .c o  m*/
        String eol = System.getProperty("line.separator");
        out = new PrintWriter(new FileWriter(export_filename));
        StringBuilder s = new StringBuilder();
        for (Node n : d.tree) {
            s.append(n.conll_fields.get(1));
            s.append("\t");
            s.append(n.conll_fields.get(3).charAt(0));
            s.append("\t");
            s.append(n.conll_fields.get(2));
            s.append("\t");
            s.append(n.conll_fields.get(4));
            s.append("\t");
            if (n.ne_annotation.length() == 0)
                n.ne_annotation = "O";
            s.append(n.ne_annotation);
            s.append(eol);
            if (n.sentEnd)
                s.append(eol);
        }
        out.print(s.toString());
        out.flush();
        out.close();
    } catch (IOException ex) {
        Logger.getLogger(Document.class.getName()).log(Level.SEVERE, null, ex);
        System.err.println("ERROR: couldn't create/open output conll file");
    }
}

From source file:de.knightsoftnet.validators.server.security.AuthFailureHandler.java

@Override
public void onAuthenticationFailure(final HttpServletRequest prequest, final HttpServletResponse presponse,
        final AuthenticationException pexception) throws IOException, ServletException {
    presponse.setStatus(HttpServletResponse.SC_UNAUTHORIZED);

    final PrintWriter writer = presponse.getWriter();
    writer.write(pexception.getMessage());
    writer.flush();
}