List of usage examples for java.io StringWriter toString
public String toString()
From source file:com.antsdb.saltedfish.sql.vdm.ExprUtil.java
/** * <p>Unescapes any Java literals found in the <code>String</code>. * For example, it will turn a sequence of <code>'\'</code> and * <code>'n'</code> into a newline character, unless the <code>'\'</code> * is preceded by another <code>'\'</code>.</p> * //from w ww. ja v a2 s.c o m * @param str the <code>String</code> to unescape, may be null * @return a new unescaped <code>String</code>, <code>null</code> if null string input */ public static String unescape(String str) { if (str == null) { return null; } try { StringWriter writer = new StringWriter(str.length()); unescapeJava(writer, str); return writer.toString(); } catch (IOException ioe) { // this should never ever happen while writing to a StringWriter throw new UnhandledException(ioe); } }
From source file:Main.java
public static String serializeXML(Node node) throws IOException { StringWriter writer = new StringWriter(); if (!serializeXmlNode(node, writer, true)) { return null; }/* ww w . jav a 2 s .c o m*/ return writer.toString(); }
From source file:Main.java
public static String toString(Document doc) throws TransformerException { StringWriter sw = new StringWriter(); TransformerFactory tfactory = TransformerFactory.newInstance(); Transformer transformer = tfactory.newTransformer(); transformer.transform(new DOMSource(doc), new StreamResult(sw)); return sw.toString(); }
From source file:Main.java
public static String getText(Node node) throws IOException { StringWriter writer = new StringWriter(); if (!serializeXmlNode(node, writer, false)) { return null; }/*www .jav a 2 s . co m*/ return writer.toString(); }
From source file:com.mber.client.HTTParty.java
private static String toString(final InputStream input) throws IOException { StringWriter writer = new StringWriter(); IOUtils.copy(input, writer, "UTF-8"); return writer.toString(); }
From source file:com.adaptris.util.text.mime.PartIteratorCase.java
protected static String toString(byte[] b) throws Exception { StringWriter out = new StringWriter(); try (InputStream in = new ByteArrayInputStream(b)) { IOUtils.copy(in, out, Charset.defaultCharset()); }// ww w . j a v a 2 s . c o m return out.toString(); }
From source file:com.stratuscom.harvester.Utils.java
public static String stackTrace(Throwable t) { StringWriter s = new StringWriter(); PrintWriter pw = new PrintWriter(s); t.printStackTrace(pw);// w w w . java2s.c o m return s.toString(); }
From source file:it.itis.pertini.falessi.tunes.services.AbstractService.java
protected static ErrorMessage toErrorMessage(SQLException e) { ErrorMessage errorMessage = new ErrorMessage(); errorMessage.setErrorCode(e.getErrorCode()); errorMessage.setSqlState(e.getSQLState()); StringWriter stringWriter = new StringWriter(); e.printStackTrace(new PrintWriter(stringWriter)); errorMessage.setStackTrace(stringWriter.toString()); return errorMessage; }
From source file:Main.java
public static String serializeElement(Element element) throws TransformerFactoryConfigurationError, TransformerException { String serializedElement = null; if (element != null) { StringWriter output = new StringWriter(); Transformer transformer = TransformerFactory.newInstance().newTransformer(); transformer.transform(new DOMSource(element), new StreamResult(output)); serializedElement = output.toString(); }/*from w w w. j a v a2 s . co m*/ return serializedElement; }
From source file:at.gv.egovernment.moa.id.auth.builder.SendAssertionFormBuilder.java
private static String getTemplate(InputStream input) { String template = null;// w ww.j a va 2s. c om try { StringWriter writer = new StringWriter(); IOUtils.copy(input, writer); template = writer.toString(); template = template.replace(URL, SERVLET); } catch (Exception e) { Logger.error("Failed to read template", e); } finally { try { input.close(); } catch (IOException e) { Logger.warn("SendAssertionTemplate inputstream can not be closed.", e); } } return template; }