Examples of StringWriter


Examples of java.io.StringWriter

    /**
     * Read fully from reader
     */
    public final static String readFully(Reader reader) throws IOException {
        StringWriter writer = new StringWriter();
        copy(reader, writer, 1024);
        return writer.toString();
    }
View Full Code Here

Examples of java.io.StringWriter

    /**
     * Read fully from stream
     */
    public final static String readFully(InputStream input) throws IOException {
        StringWriter writer = new StringWriter();
        InputStreamReader reader = new InputStreamReader(input);
        copy(reader, writer, 1024);
        return writer.toString();
    }
View Full Code Here

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

Examples of java.io.StringWriter

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

Examples of java.io.StringWriter

        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

Examples of java.io.StringWriter

   
    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

Examples of java.io.StringWriter

          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

Examples of java.io.StringWriter

         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

Examples of java.io.StringWriter

    @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

Examples of java.io.StringWriter

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