Package java.io

Examples of java.io.Writer


    // TODO consider merging two pieces below, generally if session is
    // stored,
    // it shouldn't be invalidated
    File sf = getPersistentFile();
    if (sf != null && sessions != null) {
      Writer w = null;
      try {
        w = new FileWriter(sf);
        sessions.save(w);
        log("TJWS: Sessions stored.");
      } catch (IOException ioe) {
        log("TJWS: IO error in storing sessions " + ioe);
      } catch (Throwable t) {
        if (t instanceof ThreadDeath)
          throw (ThreadDeath) t;
        log("TJWS: Unexpected problem in storing sessions " + t);
      } finally {
        try {
          w.close();
        } catch (Exception e) {
        }
      }

      Enumeration e = sessions.keys();
View Full Code Here


public class Generator {
 
  public static void main(String[] args) throws IOException {
    Reader reader = null;
    Writer writer = null;
    try {
      reader = new FileReader(new File("/home/tbinias/eclipse/plugin-dev/WGAEclipseEditors/resources/wga/tmlTagDefinitionsXStream.xml"));
      TMLTagDefinitions def = TMLTagDefinitions.fromXML(reader);
      def.getTagByName("item").getValidators().add("de.innovationgate.test");
      writer = new FileWriter(new File("/tmp/defout.xml"));
      def.toXML(def, writer);
    } finally {
      if (reader != null) {
        reader.close();
      }
      if (writer != null) {
        writer.close();
      }
    }
   
  }
View Full Code Here

                c = (char) r.nextInt();
            } while (c >= 0xd800 && c <= 0xdfff);
            data[i] = c;
        }
        Clob c = conn.createClob();
        Writer out = c.setCharacterStream(1);
        out.write(data, 0, data.length);
        out.close();
        stat.execute("delete from test");
        PreparedStatement prep = conn.prepareStatement("insert into test values(?, ?)");
        prep.setInt(1, 1);
        prep.setClob(2, c);
        prep.execute();
View Full Code Here

            OutputStream outS = Channels.newOutputStream(out);
           
            if (stylesheet != null) {
              outS.write(("<?xml-stylesheet type=\"text/xsl\" href=\""+stylesheet+"\"?>\n").getBytes("utf-8"));
            }
            Writer outW = new OutputStreamWriter(outS, "utf-8");
            new Serializer().serialize(model, "", outW);
            outW.flush();
            //model.write(outS);
            outS.close();
          }
         
        });
View Full Code Here

     * whatever the encoding
     * @throws IOException on error
     */   
    public static void exportToXML(List list, OutputStream out, String encoding, boolean onlyASCII) throws IOException {
        String jenc = IanaEncodings.getJavaEncoding(encoding);
        Writer wrt = new BufferedWriter(new OutputStreamWriter(out, jenc));
        exportToXML(list, wrt, encoding, onlyASCII);
    }
View Full Code Here

        String init2 = getBaseDir() + "/test-init-2.sql";

        // Create two scripts that we will run via "INIT"
        IOUtils.createDirs(init1);

        Writer w = new OutputStreamWriter(IOUtils.openFileOutputStream(init1, false));

        PrintWriter writer = new PrintWriter(w);
        writer.println("create table test(id int identity, name varchar);");
        writer.println("insert into test(name) values('cat');");
        writer.close();
View Full Code Here

  // if (summarydir != null) {
  // outputDir = summarydir;
  // }

  PrintStream outputStream = null;
  Writer overallsummary = null;
  Writer overallsummaryerrors = null;
  try {
      outputStream = getSummaryStream(summarydir,
        "Summary_" + querysetname + "_" + scenario_name, true); //$NON-NLS-1$
     
      overallsummary = getOverallSummaryStream(summarydir);
      overallsummaryerrors = getOverallSummaryErrorsStream(summarydir);
  } catch (IOException e) {
      e.printStackTrace();
      //              logError("Unable to get output stream for file: " + outputFileName); //$NON-NLS-1$
      throw e;
  }

  outputStream
    .println("Scenario " + scenario_name + " Summary [" + this.resultMode + "]"); //$NON-NLS-1$
  outputStream.println("Query Set Name " + querysetname); //$NON-NLS-1$
  outputStream.println("=================="); //$NON-NLS-1$

  outputStream.println("Number of Test Query Sets: " + total_querysets); //$NON-NLS-1$ //$NON-NLS-2$

  outputStream.println("=================="); //$NON-NLS-1$
  outputStream.println("Test Query Set"); //$NON-NLS-1$
  outputStream
    .println("\t" + "Name" + "\t\t\t\t" + "Pass" + "\t" + "Fail" + "\t" + "Total" + "\t" + "Time(sec)"); //$NON-NLS-1$

  if (!this.query_sets.isEmpty()) {
      // sort so that like failed queries are show together
      Collections.sort(this.query_sets);
     
      for (Iterator<String> it = this.query_sets.iterator(); it.hasNext();) {
    outputStream.println(it.next()); //$NON-NLS-1$ //$NON-NLS-2$
      }

  }
  outputStream.println("=================="); //$NON-NLS-1$

  outputStream.println("\t" + "Totals" + "\t\t\t\t" + total_pass + "\t"
    + total_fail + "\t" + total_queries + "\t" + total_seconds
    / 1000);
 
 
  try {
      overallsummary.write( pad(scenario_name, 30, ' ') + " \t" + total_pass + "\t" + total_fail + "\t" + total_queries + "\n");
      overallsummary.flush();

  } catch (IOException ioe) {
      ioe.printStackTrace();
  } finally {                       // always close the file
      try {
    overallsummary.close();
      } catch (IOException ioe2) {
      // just ignore it
      }
  } //

  // outputStream
  //      .println("Number of Queries: " + total_queries); //$NON-NLS-1$ //$NON-NLS-2$
  // outputStream
  //      .println("Number Passed    : " + total_pass); //$NON-NLS-1$ //$NON-NLS-2$
  // outputStream
  //      .println("Number Failed    : " + total_fail); //$NON-NLS-1$ //$NON-NLS-2$

  if (!this.failed_queries.isEmpty()) {
      // sort so that like failed queries are show together
      Collections.sort(this.failed_queries);

      outputStream.println("\n\n=================="); //$NON-NLS-1$
      outputStream.println("Failed Queries"); //$NON-NLS-1$ 
     
      overallsummaryerrors.write("\n" + scenario_name + "\n");


      for (Iterator<String> it = this.failed_queries.iterator(); it
        .hasNext();) {
    String error = it.next();
    outputStream.println("\t - " + error); //$NON-NLS-1$ //$NON-NLS-2$
    // write all errors to the summary file
    overallsummaryerrors.write("\t\t" + error + "\n");


      }
     
    try {
        overallsummaryerrors.flush();

    } catch (IOException ioe) {
        ioe.printStackTrace();
    } finally {                       // always close the file
        try {
      overallsummaryerrors.close();
        } catch (IOException ioe2) {
        // just ignore it
        }
    } //
View Full Code Here

    private void writeSchemas(File destdir) throws JiBXException, IOException {
        for (Iterator iter = m_validationContext.iterateSchemas(); iter.hasNext();) {
            SchemaElement schema = (SchemaElement)iter.next();
            File file = new File(destdir, schema.getResolver().getName());
            OutputStream stream = new FileOutputStream(file);
            Writer writer = new OutputStreamWriter(stream, "utf-8");
            IBindingFactory factory = BindingDirectory.getFactory(SchemaUtils.XS_PREFIX_BINDING, SchemaElement.class);
            IMarshallingContext ictx = factory.createMarshallingContext();
            ictx.setOutput(writer);
            ictx.setIndent(2);
            ictx.marshalDocument(schema);
            writer.close();
        }
    }
View Full Code Here

   * Generates a stacktrace in the form of a string
   * @param exception Exception to make stacktrace of
   * @return Stacktrace of exception in the form of a string
   */
  private static String generateStacktrace(Exception exception) {
    Writer result = new StringWriter();
    PrintWriter printWriter = new PrintWriter(result);
    exception.printStackTrace(printWriter);
    return result.toString();
  }
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(null);
    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

TOP

Related Classes of java.io.Writer

Copyright © 2015 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.