Examples of BufferedWriter


Examples of java.io.BufferedWriter

  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;
View Full Code Here

Examples of java.io.BufferedWriter

    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.BufferedWriter

    private void initWrite() throws IOException {
        if (output == null) {
            try {
                OutputStream out = IOUtils.openFileOutputStream(fileName, false);
                out = new BufferedOutputStream(out, Constants.IO_BUFFER_SIZE);
                output = new BufferedWriter(new OutputStreamWriter(out, characterSet));
            } catch (Exception e) {
                close();
                throw DbException.convertToIOException(e);
            }
        }
View Full Code Here

Examples of java.io.BufferedWriter

        try {
            w = new OutputStreamWriter(IOUtils.openFileOutputStream(fileName, false));
        } catch (Exception e) {
            throw DbException.convertToIOException(e);
        }
        PrintWriter writer = new PrintWriter(new BufferedWriter(w));
        while (true) {
            String line = r.readLine();
            if (line == null) {
                break;
            }
View Full Code Here

Examples of java.io.BufferedWriter

                            model.delete();
                        }
                        model.createNewFile();
                       
                        // now print out the class details by package
                        BufferedWriter writer = new BufferedWriter(new FileWriter(model));
                        DataModelUtils.writeImage(m_packageDirectory, writer);
                        writer.close();
                       
                    }
                } else {
                    handler.terminate("Terminating due to errors in normalized schemas - please report the problem");
                    return false;
View Full Code Here

Examples of java.io.BufferedWriter

                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.BufferedWriter

    * @param path
    */
   public void logHTMLContext(String path)
   {
      String source = getHtmlSource();
      BufferedWriter writer = null;
      try
      {
         writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path)));
         writer.write(source);
         writer.flush();
      }
      catch (Exception e)
      {
         throw new RuntimeException("Unable to save HTML body", e);
      }
      finally
      {
         try
         {
            writer.close();
         }
         catch (Exception e)
         {
         }
      }
View Full Code Here

Examples of java.io.BufferedWriter

    FtpClient ftpClient = new FtpClient(ftpURL.host);
    ftpClient.login(ftpURL.user,ftpURL.pass);
    ftpClient.binary();
    ftpClient.cd(ftpURL.dir);

    BufferedWriter writer;
    Any result;

    switch (type) {

    case StreamUtils.TYPE_STRING:
      writer = new BufferedWriter(new OutputStreamWriter(ftpClient.put(ftpURL.file)));
      writer.write(anyData.toString());
      writer.close();
      result = Any.TRUE;
      break;

    case StreamUtils.TYPE_LINES:
      writer = new BufferedWriter(new OutputStreamWriter(ftpClient.put(ftpURL.file)));
      result = StreamUtils.linesToWriter(anyData,writer);
      break;

    case StreamUtils.TYPE_BINARY:
      OutputStream out = ftpClient.put(ftpURL.file);
View Full Code Here

Examples of java.io.BufferedWriter

    FtpClient ftpClient = new FtpClient(ftpURL.host);
    ftpClient.login(ftpURL.user,ftpURL.pass);
    ftpClient.binary();
    ftpClient.cd(ftpURL.dir);

    BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(ftpClient.put(ftpURL.file)));
    writer.write(string);
    writer.close();
    Any result = Any.TRUE;
    try {
      ftpClient.closeServer();
    } catch (Exception e) {
      //anvil.Log.log().error("Can not close ftp connection");
View Full Code Here

Examples of java.io.BufferedWriter

        comp.writeResults();
    }

    private void writeResults() {
        try {
            BufferedWriter writer = new BufferedWriter(new FileWriter(file));
            StringBuffer res = new StringBuffer("<document>\n" + "<properties>\n" + "<title>Performance comparison with HashMap</title>\n" + "</properties>\n"
                    + "<body>" +
                        "<section name=\"Test harness\"><p>All tests will be successfull " +
                        "50% of the time, the other 50% will not be successfull, since the" +
                        "Maps is pre-initialized for each test with keys/values 0-500, and the tests are runned with" +
                        "keys/values 0-1000." +
                        "The keys are Strings, while the values are integers.</p></section>" +
                        "<section name=\"Performance metrics\">\n"
                    + "<p>This page presents the results of executing a performance test of FKache versus java.util.HashMap.\n");
            res.append("The tests was performed on "+ DateFormat.getDateTimeInstance().format(new Date())+".\n");
            res.append("The tests was runned on "+System.getProperty("java.runtime.name") +
                    " version " + System.getProperty("java.vm.version") +
                    " by " + System.getProperty("java.vm.vendor")+".\n");
            res.append("The operating system was "+ System.getProperty("os.name")+".\n");
            res.append("The amount of available memory to the VM was " + Runtime.getRuntime().maxMemory()/1024/1024 + "Mb.\n");
            if(!results.isEmpty()) {
                res.append("<table><tr><th>method</th><th>Number of repeats</th><th>HashMap</th><th>FKache</th></tr>\n");
                Iterator iter = results.keySet().iterator();
                while(iter.hasNext()) {
                    String method = (String) iter.next();
                    float[] fs = (float[]) results.get(method);
                    res.append("<tr><td>"+method+"</td><td>"+countFormat.format((long)fs[0]*1000)+"</td><td>"+100*fs[1]+"%</td><td>"+(long)(100F*fs[2])+"%</td></tr>\n");
                }
                res.append("</table>");
            }
            res.append("</p>\n</section>\n</body>\n</document>");
            writer.write(res.toString());
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
            throw new IllegalStateException("The results could not be written.");
        }
    }
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.