Example usage for java.io Writer write

List of usage examples for java.io Writer write

Introduction

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

Prototype

public void write(String str) throws IOException 

Source Link

Document

Writes a string.

Usage

From source file:com.netspective.sparx.form.handler.DialogExecuteIncludeResourceHandler.java

public void executeDialog(Writer writer, DialogContext dc) throws IOException, DialogExecuteException {
    if (path == null) {
        writer.write("No path to resource or URL provided.");
        return;//from ww  w .  j a  va 2 s. com
    }

    String includePath = getPath().getTextValue(dc);
    if (local) {
        try {
            HttpUtils.includeServletResourceContent(writer, dc, includePath, REQATTRNAME_DIALOG_CONTEXT);
        } catch (ServletException e) {
            log.error(e);
            throw new DialogExecuteException("Error including '" + includePath + "'", e);
        }
    } else
        HttpUtils.includeUrlContent(includePath, writer);
}

From source file:ductive.console.jline.JLineInteractiveTerminal.java

@Override
public OutputStream error() throws IOException {
    // FIXME: just fix me
    Writer writer = jline.getOutput();
    writer.write(new Ansi().bold().fg(Color.RED).toString());
    return new WriterOutputStream(writer);
}

From source file:au.org.ala.biocache.dao.TaxonDAOImpl.java

void outputNestedMappableLayerStart(String rank, String taxon, Writer out) throws Exception {
    out.write("<Layer queryable=\"1\"><Name>" + rank + ":" + taxon + "</Name><Title>" + taxon + "</Title>");
    out.flush();//  w ww  . ja va  2 s .c o  m
}

From source file:au.org.ala.biocache.dao.TaxonDAOImpl.java

void outputNestedLayerStart(String layerName, Writer out) throws Exception {
    out.write("<Layer><Name>" + layerName + "</Name><Title>" + layerName + "</Title>\n\t");
    out.flush();// ww w. j a  va  2 s  .com
}

From source file:au.org.ala.biocache.dao.TaxonDAOImpl.java

void outputNestedLayerEnd(Writer out) throws Exception {
    out.write("</Layer>");
    out.flush();
}

From source file:com.netxforge.oss2.config.DefaultCapsdConfigManager.java

/** {@inheritDoc} */
protected synchronized void saveXml(String xml) throws IOException {
    if (xml != null) {
        File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.CAPSD_CONFIG_FILE_NAME);
        Writer fileWriter = new OutputStreamWriter(new FileOutputStream(cfgFile), "UTF-8");
        fileWriter.write(xml);
        fileWriter.flush();/*w  ww  . j a  v a2  s .  c o m*/
        fileWriter.close();
    }
}

From source file:org.craftercms.core.util.spring.mvc.GsonView.java

@Override
protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    model = filterModel(model);//from  w  w  w .  j av  a 2 s. c om

    Writer output = response.getWriter();

    if (prefixJson) {
        output.write(JSON_ANTI_HIJACKING_PREFIX);
    }

    if (renderSingleAttributeAsRootObject && model.size() == 1) {
        gson.toJson(model.values().iterator().next(), output);
    } else {
        gson.toJson(model, output);
    }
}

From source file:com.athena.chameleon.web.system.controller.SystemController.java

/**
 *  //from   w w  w  .  j  a v a  2s. co m
 * 
 * @param request
 * @param response
 * @param modelMap
 * @param session
 * @return
 * @throws Exception
 */
@RequestMapping("/saveCode.do")
public String saveCode(HttpServletRequest request, HttpServletResponse response, ModelMap modelMap,
        HttpSession session) throws Exception {

    String filteringCode = request.getParameter("filteringCode");
    File filteringResource = new File(PropertyUtil.class.getResource("/filtering.properties").getFile());

    Writer output = new BufferedWriter(new FileWriter(filteringResource));
    output.write(filteringCode);
    output.close();

    String contextCode = request.getParameter("contextCode");
    File contextResource = new File(PropertyUtil.class.getResource("/config/context.properties").getFile());

    output = new BufferedWriter(new FileWriter(contextResource));
    output.write(contextCode);
    output.close();

    modelMap.addAttribute("result", true);
    return "jsonView";
}

From source file:com.facebook.hiveio.testing.LocalHiveServer.java

private File writeDataToFile(String tableName, String[] data) throws IOException {
    File dataFile = new File(rootDir(), tableName);
    Writer writer = Files.newWriter(dataFile, Charsets.UTF_8);
    for (String line : data) {
        writer.write(line);
        writer.write("\n");
    }//from w w w.  j ava2 s  .  c o m
    writer.close();
    return dataFile;
}

From source file:com.moss.posixfifosockets.testharness.JavaTestClient.java

@Override
String send(String message) throws Exception {

    log("Connecting to server");
    socket = PosixFifoSocket.newClientConnection(address, 1000);
    log("Using socket " + socket);
    log("Opening output ");
    Writer w = new OutputStreamWriter(socket.out());
    log("Writing message ");
    w.write(message);
    log("Closing output");
    w.close();//www  .j  a v  a  2s . c  o  m

    log("Opening response");
    BufferedReader reader = new BufferedReader(new InputStreamReader(socket.in()));

    char[] b = new char[1024];

    log("Reading response");

    StringBuilder text = new StringBuilder();
    for (int x = reader.read(b); x != -1; x = reader.read(b)) {
        text.append(b, 0, x);
    }
    log("Closing response");
    reader.close();

    log("Done (received " + message + ")");

    //         String response = reader.readLine();
    //         reader.close();
    socket.close();
    //         System.out.println("Response " + response);
    return text.toString();
}