Package java.io

Examples of java.io.StringWriter


   * each separated by a newline
   * @return
   */
  public String getCommandDescriptions()
  {
    StringWriter sw = new StringWriter();
    PrintWriter out = new PrintWriter(sw);
    for (Iterator iter = iterator(); iter.hasNext();) {
      IConsoleCommand cmd = (IConsoleCommand) iter.next();
      out.println(cmd.getCommandDescriptions());
    }
    return sw.toString();
  }
View Full Code Here


public abstract class XMLTranslator {
   
    public abstract void translate(Writer writer) throws TransformerException, IOException;
   
  public String getString() throws IOException, TransformerException {
    StringWriter writer = new StringWriter();
    this.translate(writer);
    return writer.toString();
  }
View Full Code Here

        if(this.recordQueryPlan) {
            this.annotations = new ArrayList<Annotation>();
        }
       
        if(this.recordDebug) {
            this.stringWriter = new StringWriter();
            this.debugWriter = new PrintWriter(this.stringWriter);
        }
    }
View Full Code Here

   
    JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {TranslatorMetaDataGroup.class});
    Marshaller marshell = jc.createMarshaller();
    marshell.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,new Boolean(true));
   
    StringWriter sw = new StringWriter();
    marshell.marshal(group, sw);
       
    System.out.println(sw.toString());   
   
    Unmarshaller un = jc.createUnmarshaller();
    group = (TranslatorMetaDataGroup)un.unmarshal(new StringReader(sw.toString()));
   
    tm = group.getTranslators().get(0);
   
    assertEquals("Oracle", tm.getName());
    assertEquals("desc", tm.getDescription());
View Full Code Here

          String prefix = MessageText.getString("AlertMessageBox." + log_type_s);
          log.appendText("[" + prefix.toUpperCase() + "] ");
        }
        log.appendText(message + "\n");
        if (t != null) {
          StringWriter sw = new StringWriter();
          PrintWriter pw = new PrintWriter(sw);
          t.printStackTrace(pw);
          log.appendText(sw.toString() + "\n");
        }
      }
    });
  }
View Full Code Here

         transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");

         for (Element element : extraMarkupHeaders)
         {
            DOMSource source = new DOMSource(element);
            StreamResult result = new StreamResult(new StringWriter());

            // we want to ouput xhtml text that will still work on html browsers.
            // In order to do this we need to have the script tag be not self closing
            // which it will try and do with the xml or xhtml method. If we just use
            // the html method then the other tags will not be closed.
View Full Code Here

    @Override
    public String toStandardString(MemContents state) {
      int addr = state.getLogLength();
      int data = state.getWidth();
      StringWriter ret = new StringWriter();
      ret.write("addr/data: " + addr + " " + data + "\n");
      try {
        HexFile.save(ret, state);
      } catch (IOException e) { }
      return ret.toString();
    }
View Full Code Here

        try {
            if (length <= 0) {
                length = Integer.MAX_VALUE;
            }
            int block = Math.min(BUFFER_BLOCK_SIZE, length);
            StringWriter out = new StringWriter(length == Integer.MAX_VALUE ? block : length);
            char[] buff = new char[block];
            while (length > 0) {
                int len = Math.min(block, length);
                len = in.read(buff, 0, len);
                if (len < 0) {
                    break;
                }
                out.write(buff, 0, len);
                length -= len;
            }
            return out.toString();
        } finally {
            in.close();
        }
    }
View Full Code Here

    logStream.println("[" + date.toString() + "] " + message);
  }

  public void log(String message, Throwable throwable) {
    if (throwable != null) {
      StringWriter sw;
      PrintWriter pw = new PrintWriter(sw = new StringWriter());
      throwable.printStackTrace(pw);
      // printCauses(throwable, pw);
      message = message + '\n' + sw;
    }
    log(message);
View Full Code Here

        }
    }
   
    private void performPropertyParsingViaJDTAST(final String classname, final Set<TMLScriptProperty> properties) {
        ASTParser parser = ASTParser.newParser(AST.JLS3);
        StringWriter writer = new StringWriter();
        InputStreamReader reader = new InputStreamReader(retrieveJavaSource(classname));
        try {
            WGUtils.inToOut(reader, writer, 1024);
        }
        catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        parser.setSource(writer.toString().toCharArray());
        ASTNode ast = parser.createAST(new NullProgressMonitor());
        ast.accept(new ASTVisitor() {

            private Map<String, String> _imports = new HashMap<String, String>();
           
View Full Code Here

TOP

Related Classes of java.io.StringWriter

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.