Package java.io

Examples of java.io.StringWriter


    out.endElement();
}

public String toString() {
    StringWriter sw = new StringWriter();
    writeXML(new XMLWriter(sw));
    return sw.toString();
}
View Full Code Here


    public static String convertToString(Reader reader) throws IOException {
      return new String(convertToCharArray(reader, Integer.MAX_VALUE));
    }

    public static char[] convertToCharArray(Reader reader, int length) throws IOException {
        StringWriter sb = new StringWriter();    
        write(sb, reader, length);
        return sb.toString().toCharArray();
    }
View Full Code Here

    public static String write( Document doc , String indent, boolean newlines ) throws IOException {
        if(doc == null){
            ArgCheck.isNotNull(doc,CorePlugin.Util.getString("JdomHelper.The_Document_reference_may_not_be_null_49")); //$NON-NLS-1$
        }
        XMLOutputter outputter = new XMLOutputter(getFormat(indent, newlines));
        StringWriter writer = new StringWriter();
        outputter.output( doc, writer );
       
        return writer.getBuffer().toString();
    }
View Full Code Here

          if (this.executionFactory.getXMLParamName() == null) {
            throw new WebServiceException(WSExecutionFactory.UTIL.getString("http_usage_error")); //$NON-NLS-1$
          }
          try {
            Transformer t = TransformerFactory.newInstance().newTransformer();
            StringWriter writer = new StringWriter();
            //TODO: prevent this from being too large
                t.transform(source, new StreamResult(writer));
            String param = Util.httpURLEncode(this.executionFactory.getXMLParamName())+"="+Util.httpURLEncode(writer.toString()); //$NON-NLS-1$
            endpoint = WSConnection.Util.appendQueryString(endpoint, param);
          } catch (TransformerException e) {
            throw new WebServiceException(e);
          }
        }
View Full Code Here

     * @param clob
     * @return string form of the clob passed.
     */
    public static String getString(Clob clob) throws SQLException, IOException {
        Reader reader = clob.getCharacterStream();
        StringWriter writer = new StringWriter();
        int c = reader.read();
        while (c != -1) {
            writer.write((char)c);
            c = reader.read();
        }
        reader.close();
        String data = writer.toString();
        writer.close();
        return data;       
    }
View Full Code Here

    public String toXml() {
      try {
        JAXBContext jc = JAXBContext.newInstance(new Class<?>[] {PlanNode.class});
      Marshaller marshaller = jc.createMarshaller();
      marshaller.setProperty("jaxb.formatted.output", Boolean.TRUE); //$NON-NLS-1$
      StringWriter writer = new StringWriter();
      marshaller.marshal(this, writer);
      return writer.toString();
      } catch (JAXBException e) {
        //shouldn't happen
        throw new TeiidRuntimeException(e);
      }
    }
View Full Code Here

        handleEvent(Event event)
        {
          new AEThread2("GenerateNetDiag", true)
          {
            public void run() {
              StringWriter sw = new StringWriter();
             
              PrintWriter  pw = new PrintWriter( sw );
                 
              IndentWriter iw = new IndentWriter( pw );
             
              NetworkAdmin admin = NetworkAdmin.getSingleton();
             
              admin.generateDiagnostics( iw );
             
              pw.close();
             
              final String  info = sw.toString();
             
              Logger.log( new LogEvent(LOGID, "Network Info:\n" + info));

              Utils.execSWTThread(
                new Runnable()
                {
                  public void
                  run()
                  {
                    ClipboardCopy.copyToClipBoard( info );
                  }
                });
            }
          }.start();
        }
      });
   
  // stats
 
  Label generate_stats_info = new Label(gLogging, SWT.NULL);
  Messages.setLanguageText(generate_stats_info, CFG_PREFIX + "statsinfo");

  Button generate_stats_button = new Button(gLogging, SWT.PUSH);
  Messages.setLanguageText(generate_stats_button, CFG_PREFIX + "generatediagnostics");

 
  generate_stats_button.addListener(
      SWT.Selection,
      new Listener()
      {
        public void
        handleEvent(Event event)
        {
          java.util.Set  types = new HashSet();
         
          types.add( AzureusCoreStats.ST_ALL );
         
          Map  reply = AzureusCoreStats.getStats( types );
         
          Iterator  it = reply.entrySet().iterator();
         
          StringBuffer buffer = new StringBuffer(16000);
         
          while( it.hasNext()){
           
            Map.Entry  entry = (Map.Entry)it.next();
           
            buffer.append( entry.getKey() + " -> " + entry.getValue() + "\r\n" );
          }
         
          String  str = buffer.toString();
         
          ClipboardCopy.copyToClipBoard( str );

          Logger.log( new LogEvent(LOGID, "Stats Info:\n" + str));
        }
      });

        // diagnostics

   
  Label generate_info = new Label(gLogging, SWT.NULL);

  Messages.setLanguageText(generate_info, CFG_PREFIX + "generatediagnostics.info");

  Button generate_button = new Button(gLogging, SWT.PUSH);

  Messages.setLanguageText(generate_button, CFG_PREFIX + "generatediagnostics");

  generate_button.addListener(
      SWT.Selection,
      new Listener()
      {
        public void
        handleEvent(Event event)
        {
          StringWriter sw = new StringWriter();
         
          PrintWriter  pw = new PrintWriter( sw );
         
          AEDiagnostics.generateEvidence( pw );
         
          pw.close();
         
          String  evidence = sw.toString();
         
          ClipboardCopy.copyToClipBoard( evidence );

          Logger.log( new LogEvent(LOGID, "Evidence Generation:\n" + evidence));
        }
View Full Code Here

     */
    public final static String getStackTrace(Throwable ex) {
        String result = "";
        if (ex != null) {
            try {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                ex.printStackTrace(pw);
                pw.close();
                sw.close();
                result = sw.toString();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return result;
View Full Code Here

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

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

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.