Example usage for java.io PrintWriter write

List of usage examples for java.io PrintWriter write

Introduction

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

Prototype

public void write(String s) 

Source Link

Document

Writes a string.

Usage

From source file:edu.isi.karma.webserver.ExtractSpatialInformationFromWikimapiaServiceHandler.java

public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {

    logger.debug("Request URL: " + request.getRequestURI());
    logger.debug("Request Path Info: " + request.getPathInfo());
    logger.debug("Request Param: " + request.getQueryString());

    String jsonOutput = null;/*from ww  w.  j a v  a  2s .c o  m*/

    String lon_min = request.getParameter("lon_min");
    String lat_min = request.getParameter("lat_min");
    String lon_max = request.getParameter("lon_max");
    String lat_max = request.getParameter("lat_max");
    //String type = request.getParameter("type");

    String url = "&lon_min=" + lon_min + "&lat_min=" + lat_min + "&lon_max=" + lon_max + "&lat_max=" + lat_max;

    try {
        System.out.println("Please Wait for extracting information from Web Site...");
        outputToOSM(url);
        System.out.println("You have got the OSM File at location: /tmp/GET_WIKIMAPIA.xml ...");
    } catch (SQLException e) {
        e.printStackTrace();
    }

    System.out.println("Opening PostGis Connection...");
    openConnection();
    System.out.println("Creating the CSV file from OSM file...");

    CreateWikimapiaInformation cwi = new CreateWikimapiaInformation(this.connection, this.osmFile_path);
    System.out.println("Extracting the Street Information from OSM file...");

    jsonOutput = cwi.createWikiMapiaTable();
    System.out.println("You have created the CSV file for STREETS at location:/tmp/buildings_geo.csv");

    /*Close connection*/
    this.closeConnection(this.connection);

    /*Output the JSON content to Web Page*/
    response.setCharacterEncoding("UTF8");
    PrintWriter pw = response.getWriter();
    response.setContentType(MimeType.APPLICATION_JSON);
    pw.write(jsonOutput);
    return;

}

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

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

    PsSeller seller = (PsSeller) request.getSession().getAttribute("currentSeller");
    if (seller == null) {
        //         http://bowen_ultimate:8080/C1_ParknShop/seller/sellerlogin
        response.sendRedirect("/C1_ParknShop/sellerLogin.jsp");
        return;//from  w ww.  ja  va2  s  .  co  m
    }

    Set<PsShop> shops = seller.getPsShops();
    Iterator<PsShop> it = shops.iterator();
    List<PsOrder> orders = new ArrayList<PsOrder>();
    List<SellerOrderDisplay> orderDisplays = new ArrayList<SellerOrderDisplay>();

    //List<ROrderItem> orderItems = new ArrayList<ROrderItem>();

    while (it.hasNext()) {
        PsShop shop = it.next();
        orders.addAll(psOrderDao.findByShopId(shop.getId()));
    }

    for (PsOrder order : orders) {

        Iterator<ROrderItem> iterator = order.getROrderItems().iterator();
        while (iterator.hasNext()) {

            ROrderItem orderItem = iterator.next();

            SellerOrderDisplay sellerOrderDisplay = new SellerOrderDisplay();
            sellerOrderDisplay.setId(order.getId());
            sellerOrderDisplay.setItemPic(orderItem.getPsItem().getUrlPicture());
            sellerOrderDisplay.setItemName(orderItem.getPsItem().getName());
            sellerOrderDisplay.setSoldTime(order.getTimeCreated());
            sellerOrderDisplay.setPrice(orderItem.getPsItem().getPrice());
            sellerOrderDisplay.setQuantity(orderItem.getQuantitiy());
            sellerOrderDisplay.setBuyerName(order.getPsCustomer().getName());
            sellerOrderDisplay.setState(order.getStatus());
            sellerOrderDisplay.setAddress(order.getPsRecipient().getAddresss());
            sellerOrderDisplay.setPhone(order.getPsRecipient().getPhoneNumber());

            orderDisplays.add(sellerOrderDisplay);
        }
        //orderItems.addAll(iROrderItemDAO.findByOrderId(order.getId()));
    }

    System.out.println(orderDisplays.size());

    /*JsonConfig jsonConfig = new JsonConfig();
     jsonConfig.setIgnoreDefaultExcludes(false);
    jsonConfig.setExcludes(new String[]{"psShop"});
    jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.LENIENT);*/

    /*jsonConfig.registerJsonValueProcessor(ROrderItem.class,
    new ObjectJsonValueProcessor(new String[]{"quantity"}, ROrderItem.class));*/

    JSONArray jsonArray = JSONArray.fromObject(orderDisplays);

    System.out.println(jsonArray.toString());
    PrintWriter out = response.getWriter();
    out.write(jsonArray.toString());
    out.flush();
    out.close();

}

From source file:com.greenpepper.html.HtmlExample.java

private void printStartTag(PrintWriter out) {
    out.write(startTag.substring(0, startTag.length() - 1));
    if (!styles.isEmpty())
        out.write(String.format(" style=\"%s\" ", inlineStyle()));
    if (!cssClasses.isEmpty())
        out.write(String.format(" class=\"%s\" ", StringUtils.join(cssClasses, " ")));
    if (status != null) {
        out.write(String.format(" data-gp-status=\"%s\" ", status.getGpStatusTag()));
    }//from   w ww . j a v  a  2s. co  m
    out.write(">");
}

From source file:com.log4ic.compressor.utils.Compressor.java

/**
 * ??/*from  w  w w.j a  v  a  2 s . c o  m*/
 *
 * @param code
 * @param type
 * @param response
 * @throws com.log4ic.compressor.exception.CompressionException
 *
 */
private static void writeOutCode(String code, FileType type, HttpServletResponse response)
        throws CompressionException {
    //mine type
    try {
        switch (type) {
        case JS:
            response.setContentType("text/javascript");
            break;
        case CSS:
        case GSS:
        case LESS:
        case MSS:
            response.setContentType("text/css");
            break;
        default:
            response.setContentType("text/html");
        }
        PrintWriter writer = response.getWriter();
        writer.write(code);
        writer.flush();
        response.flushBuffer();
    } catch (IOException e) {
        throw new CompressionException("Write code to client error.", e);
    }
}

From source file:com.greenpepper.html.HtmlExample.java

/** {@inheritDoc} */
public void print(PrintWriter out) {
    out.write(lead);
    printStartTag(out);/*from   w ww. j a  va  2 s .co m*/
    if (child != null)
        child.print(out);
    else
        out.write(text);
    out.write(endTag);
    if (sibling != null)
        sibling.print(out);
    else
        out.write(tail);
}

From source file:com.hihsoft.sso.business.web.controller.TsysModuleinfoController.java

@RequestMapping(params = "method=queryList")
public ModelAndView queryList(final HttpServletRequest request, final HttpServletResponse response)
        throws Exception {
    final String hql = "from TsysModuleinfo";
    String pageSize = request.getParameter("rows");
    final String pageNo = request.getParameter("page");
    if (pageSize == null)
        pageSize = "10";
    if (pageNo == null)
        pageSize = "1";
    final List list = tsysModuleinfoService.getTsysModuleinfoPageDataByHQL(hql, new Object[] {},
            Integer.parseInt(pageSize), Integer.parseInt(pageNo));
    final int total = tsysModuleinfoService.getDataTotalNum(hql);
    final String result = "{\"total\": " + total + ", \"rows\": "
            + JsonUtil.toString(list, JsonUtil.COLLECTION_FILTER) + "}";
    final PrintWriter out = response.getWriter();
    out.write(result);
    return null;/* w w  w  .  j  av a2  s. c  om*/
}

From source file:org.ala.spatial.web.services.MaxentWSController.java

private String writeFile(String contents, String outputpath, String filename) {
    try {/*w  w  w .  ja  v a  2 s. com*/
        File fDir = new File(outputpath);
        fDir.mkdir();

        File spFile = new File(fDir, filename);
        PrintWriter spWriter = new PrintWriter(new BufferedWriter(new FileWriter(spFile)));

        spWriter.write(contents);
        spWriter.close();

        return spFile.getAbsolutePath();
    } catch (IOException ex) {
        System.out.println("error writing species file:");
        ex.printStackTrace(System.out);
    }

    return null;
}

From source file:com.bc.fiduceo.ingest.IngestionTool.java

void printUsageTo(OutputStream outputStream) {
    final String ls = System.lineSeparator();
    final PrintWriter writer = new PrintWriter(outputStream);
    writer.write("ingestion-tool version " + VERSION_NUMBER);
    writer.write(ls + ls);/*  w  ww. ja v  a 2  s  . c om*/

    final HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.printHelp(writer, 120, "ingestion-tool <options>", "Valid options are:", getOptions(), 3, 3,
            "");

    writer.flush();
}

From source file:com.mycompany.bankinterface.service.GetUserData.java

private void writeJsonError(String message, PrintWriter pw) {
    JSONObject jo = new JSONObject();
    jo.put("status", ServiceResponseStatus.Error);
    jo.put("message", message);
    pw.write(jo.toString());

    logger.error("Returning error -->" + message + "<--");
}

From source file:nl.minbzk.dwr.zoeken.enricher.uploader.ACIResultUploader.java

/**
 * {@inheritDoc}/*from ww w.  j  av  a  2  s  .  co m*/
 */
@Override
public void writeOut(final String databaseName, final PrintWriter writer) {
    writer.write(String.format("ACI database %s", databaseName));
}