Package java.io

Examples of java.io.Writer


    if (styleFile != null)
    {
      final String encoding = configuration.getConfigProperty
          (HtmlTableModule.ENCODING, EncodingRegistry.getPlatformDefaultEncoding());
      final Writer styleOut = new OutputStreamWriter
          (new BufferedOutputStream(styleFile.getOutputStream()), encoding);
      styleManager.write(styleOut);
      styleOut.flush();
      styleOut.close();

      if (isForceBufferedWriting() == false)
      {
        // A complete header had been written when the processing started ..
        this.xmlWriter.writeCloseTag(); // for the body tag
View Full Code Here


    {
      throw new IOException("The specified report definition was not found");
    }
    final File out = new File(outFile);
    final OutputStream base = new FileOutputStream(out);
    final Writer w = new BufferedWriter(new OutputStreamWriter(base, encoding));
    try
    {
      convertReport(reportURL, out.toURL(), w, encoding);
    }
    finally
    {
      w.close();
    }
  }
View Full Code Here

   */
  public void convertReport(final File in, final File out, final String encoding)
      throws IOException, ReportWriterException
  {
    final OutputStream base = new FileOutputStream(out);
    final Writer w = new BufferedWriter
        (new OutputStreamWriter(base, encoding));
    try
    {
      convertReport(in.toURL(), out.toURL(), w, encoding);
    }
    finally
    {
      w.close();
    }
  }
View Full Code Here

  public void testDataSourceWriter() throws Exception
  {
    final ReportWriter writer = createWriter();
    final StaticDataSource ds = new StaticDataSource(new Line2D.Float());
    final ClassFactory cc = writer.getClassFactoryCollector();
    final Writer w = new OutputStreamWriter(new NullOutputStream(), "UTF-16");
    final XmlWriter xmlWriter = new XmlWriter(w);

    final AttributeList attList = new AttributeList();
    attList.addNamespaceDeclaration("", ExtParserModule.NAMESPACE);
    xmlWriter.writeTag(ExtParserModule.NAMESPACE, "testcase", attList, XmlWriter.OPEN);
    final DataSourceWriter dsW = new DataSourceWriter(writer,
        ds, cc.getDescriptionForClass(ds.getClass()), xmlWriter);
    dsW.write();
    xmlWriter.writeCloseTag();
    w.flush();
  }
View Full Code Here

  /**
   * Exports the report into a CSV file.
   */
  public void run()
  {
    Writer out = null;
    final File file = new File(fileName);
    try
    {
      final File directory = file.getAbsoluteFile().getParentFile();
      if (directory != null)
      {
        if (directory.exists() == false)
        {
          if (directory.mkdirs() == false)
          {
            CSVDataExportTask.logger.warn("Can't create directories. Hoping and praying now.."); //$NON-NLS-1$
          }
        }
      }

      final String encoding = report.getConfiguration().getConfigProperty
          (CSVProcessor.CSV_ENCODING, EncodingRegistry.getPlatformDefaultEncoding());
      out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), encoding));

      final CSVProcessor target = new CSVProcessor(report);
      if (progressDialog != null)
      {
        progressDialog.setModal(false);
        progressDialog.setVisible(true);
        target.addReportProgressListener(progressDialog);
      }
      target.setWriter(out);
      target.processReport();
      out.close();
      out = null;

      if (progressDialog != null)
      {
        target.removeReportProgressListener(progressDialog);
      }

      if (statusListener != null)
      {
        statusListener.setStatus
            (StatusType.INFORMATION, messages.getString("CSVRawExportTask.USER_TASK_COMPLETE"), null); //$NON-NLS-1$
      }
    }
    catch (ReportInterruptedException re)
    {
      if (statusListener != null)
      {
        statusListener.setStatus
            (StatusType.INFORMATION, messages.getString("CSVRawExportTask.USER_TASK_ABORTED"), null); //$NON-NLS-1$
      }
      try
      {
        out.close();
        out = null;
        if (file.delete() == false)
        {
          CSVDataExportTask.logger.warn("Unable to delete incomplete export:" + file); //$NON-NLS-1$
        }
      }
      catch (SecurityException se)
      {
        // ignore me
      }
      catch (IOException ioe)
      {
        // ignore me...
      }
    }
    catch (Exception re)
    {
      CSVDataExportTask.logger.error("Exporting failed .", re); //$NON-NLS-1$
      if (statusListener != null)
      {
        statusListener.setStatus
            (StatusType.ERROR, messages.getString("CSVRawExportTask.USER_TASK_FAILED"), re); //$NON-NLS-1$
      }
    }
    finally
    {
      try
      {
        if (out != null)
        {
          out.close();
        }
      }
      catch (Exception e)
      {
        if (statusListener != null)
View Full Code Here

    // prepare anything that might needed to be prepared ..
    final String encoding = metaData.getConfiguration().getConfigProperty
        ("org.pentaho.reporting.engine.classic.core.modules.output.pageable.xml.Encoding",
            EncodingRegistry.getPlatformDefaultEncoding());

    final Writer writer = new BufferedWriter(new OutputStreamWriter(outputStream, encoding));
    this.xmlWriter = new XmlWriter(writer, td);
    this.xmlWriter.writeXmlDeclaration(encoding);
    final AttributeList attrs = new AttributeList();
    attrs.addNamespaceDeclaration("", XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE);
    xmlWriter.writeTag(XmlDocumentWriter.LAYOUT_OUTPUT_NAMESPACE, "layout-output", attrs, XmlWriter.OPEN);
View Full Code Here

                               final String encoding)
      throws ReportProcessingException, IOException
  {
    final CSVProcessor pr = new CSVProcessor(report);
    final FileOutputStream outstr = new FileOutputStream(filename);
    final Writer fout = new BufferedWriter(new OutputStreamWriter(outstr, encoding));
    pr.setWriter(fout);
    pr.processReport();
    fout.close();
  }
View Full Code Here

                               final OutputStream outputStream,
                               final String encoding)
      throws ReportProcessingException, IOException
  {
    final CSVProcessor pr = new CSVProcessor(report);
    final Writer fout = new BufferedWriter(new OutputStreamWriter(outputStream, encoding));
    pr.setWriter(fout);
    pr.processReport();
    fout.flush();
  }
View Full Code Here

   * @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

    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

TOP

Related Classes of java.io.Writer

Copyright © 2018 www.massapicom. 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.