Examples of Writer


Examples of java.io.Writer

   * @param fileName target file name.
   * @return <code>true</code> if the export succeeded, and <code>false</code> otherwise.
   */
  public boolean saveXML(final MasterReport report, final String fileName)
  {
    Writer out = null;
    try
    {
      out = new BufferedWriter(new FileWriter(new File(fileName)));

      final XMLProcessor xprc = new XMLProcessor(report);
      xprc.setWriter(out);
      xprc.processReport();
      return true;
    }
    catch (Exception e)
    {
      System.err.println("Writing PDF failed.");
      System.err.println(e.toString());
      return false;
    }
    finally
    {
      try
      {
        if (out != null)
        {
          out.close();
        }
      }
      catch (Exception e)
      {
        System.err.println("Saving XML failed.");
View Full Code Here

Examples of java.io.Writer

    final DefaultTagDescription td = new DefaultTagDescription();
    td.addDefaultDefinition(LAYOUT_OUTPUT_NAMESPACE, false);
    td.addTagDefinition(LAYOUT_OUTPUT_NAMESPACE, "text", true);

    // prepare anything that might needed to be prepared ..
    final Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream));
    this.xmlWriter = new XmlWriter(writer, td);
    this.xmlWriter.writeXmlDeclaration(null);
    final AttributeList attrs = new AttributeList();
    attrs.addNamespaceDeclaration("", LAYOUT_OUTPUT_NAMESPACE);
    xmlWriter.writeTag(LAYOUT_OUTPUT_NAMESPACE, "layout-output", attrs, XmlWriter.OPEN);
View Full Code Here

Examples of java.io.Writer

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        store(out, null);
        ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
        InputStreamReader reader = new InputStreamReader(in, "ISO8859-1");
        LineNumberReader r = new LineNumberReader(reader);
        Writer w;
        try {
            w = new OutputStreamWriter(IOUtils.openFileOutputStream(fileName, false));
        } catch (Exception e) {
            throw DbException.convertToIOException(e);
        }
View Full Code Here

Examples of java.io.Writer

        try {
            String location = (String) ActionContext.getContext().get("template");
            Template template = velocityManager.getVelocityEngine().getTemplate(location);

            Writer writer = pageContext.getOut();
            template.merge(resultContext, writer);
            writer.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            // perform cleanup
            jspFactory.releasePageContext(pageContext);
View Full Code Here

Examples of java.io.Writer

                m_writer.setIndentSpaces(m_indentCount, m_newLine,
                     m_indentChar);
            }
           
            // handle encoding using standard libraries
            Writer writer = new BufferedWriter
                (new OutputStreamWriter(outs, enc));
            ((GenericXMLWriter)m_writer).setOutput(writer, esc);
            reset();
           
        } catch (IOException ex) {
View Full Code Here

Examples of java.io.Writer

     
      // add new item into the feature list
      homePageContent = homePageContent.replaceAll("<li>Internationalization support</li>", "<li>Internationalization support</li>\n<li id=\"newFeature\">" + newFeature + "</li>");
     
      // write new content
      Writer writer = null;
      try
      {
         writer = new OutputStreamWriter(new FileOutputStream(homePageLocation));
         writer.write(homePageContent);
         writer.flush();
      }
      catch (IOException e)
      {
         throw new RuntimeException("Unable write modified home page " + homePageLocation);
      }
      finally
      {
         try
         {
            writer.close();
         }
         catch (IOException e)
         {
            throw new RuntimeException("Unable to close home page reader.");
         }
View Full Code Here

Examples of java.io.Writer

      conn.setAutoCommit(false);
      stmt = conn.prepareStatement(query);
      rs = stmt.executeQuery();
      int i = 0;
      if (rs.next() && i < parameters.length) {
        Writer writer = null;
        try {
          String param = parameters[i++].toString();
          CLOB clob = (CLOB)rs.getClob(i);
          writer = clob.getCharacterOutputStream();
          writer.write(param.toCharArray(), 0, param.length());
        } finally {
          try {
            if (writer != null) {
              writer.close();
            }
          } catch (Throwable t) {
          }
        }
      }
View Full Code Here

Examples of java.io.Writer

        XQueryModule module = proc.parse(input, baseUri);
        // #2 execute the compiled expression using ``pull'' mode
        Sequence<? extends Item> result = proc.execute(module);

        // prepare SAX result handler
        Writer writer = new NoopWriter();
        SAXWriter saxHandler = new SAXWriter(writer, "UTF-8"); // SAXWriter implements ContentHandler
        saxHandler.setPrettyPrint(true); // enabled formatting
        saxHandler.setXMLDeclaration(true); // insert XML declaration to output
        Serializer ser = new SAXSerializer(saxHandler);
        ser.emit(result); // emit SAX events to SAX handler
View Full Code Here

Examples of java.io.Writer

        XQueryProcessor proc = new XQueryProcessor();
        // #1 parse a query
        XQueryModule module = proc.parse(input);

        // prepare a result handler (StAX)
        Writer writer = new StringWriter();
        XMLOutputFactory factory = XMLOutputFactory.newInstance();
        XMLStreamWriter streamWriter = factory.createXMLStreamWriter(writer);
        XQEventReceiver handler = new StAXSerializer(streamWriter);

        // #2 execute the compiled expression using ``push'' mode
        //   In push mode, the result is directed to the events.
        proc.execute(module, handler);

        streamWriter.flush(); // flushing is required
        System.out.println(writer.toString());
    }
View Full Code Here

Examples of java.io.Writer

        // Check to see if the Writer in the Event was used. If it
        // was, then the listeners contributed concatenated text, and
        // the result needs to be retrieved and sent back.
        if (event.isWriterUsed()) {
            Writer writer = event.getWriter();
            String result = writer.toString();
            writeHttpResponse(out, null, result);
        }

        // else - assume that the binary response listeners took care
        // of writing things back on their own,
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.