List of usage examples for java.io StringWriter toString
public String toString()
From source file:com.ontotext.s4.multiThreadRequest.utils.Util.java
public static String convertSreamToString(InputStream inputStream) throws IOException { StringWriter writer = new StringWriter(); IOUtils.copy(inputStream, writer, UTF_8_ENCODING); String theString = writer.toString(); return theString; }
From source file:com.xyxy.platform.modules.extension.tools.FreeMarkers.java
/** * Template./* w w w.j a v a 2 s . c o m*/ */ public static String renderTemplate(Template template, Object model) { try { StringWriter result = new StringWriter(); template.process(model, result); return result.toString(); } catch (Exception e) { throw Exceptions.unchecked(e); } }
From source file:com.autentia.tnt.util.BeanUtils.java
/** * Devuelve la pila de una excepcion/*from w w w . j a va 2s .c o m*/ * @param ex la excepcion * @return la pila de la excepcion */ public static String getErrorDesc(Throwable ex) { StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); //NOSONAR return sw.toString(); }
From source file:Main.java
public static String format(Node node) throws TransformerException { final StringWriter writer = new StringWriter(); format(new DOMSource(node), false, new StreamResult(writer)); return writer.toString(); }
From source file:net.fizzl.redditengine.data.UserListing.java
public static UserListing fromInputStream(InputStream in) throws IOException { StringWriter writer = new StringWriter(); IOUtils.copy(in, writer, "UTF-8"); return fromInputStream(writer.toString()); }
From source file:Main.java
/** * /*from ww w.ja v a 2 s. co m*/ * @param object * @return * @throws JAXBException */ public static String pojoToXml(Object object) throws JAXBException { JAXBContext context = JAXBContext.newInstance(object.getClass()); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); // marshaller.setProperty(Marshaller.JAXB_ENCODING, "U"); StringWriter writer = new StringWriter(); marshaller.marshal(object, writer); String xmlData = writer.toString(); return xmlData; }
From source file:Main.java
public static void printE(String tag, Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw);/*from w w w . ja va2 s.c om*/ Log.e(tag, sw.toString()); }
From source file:Main.java
public static String getDocumentAsString(Document doc) throws TransformerException { StringWriter sw = new StringWriter(); tf.newTransformer().transform(new DOMSource(doc), new StreamResult(sw)); return sw.toString(); }
From source file:Main.java
public static <T extends Object> String marshalAsString(Class clz, T marshalObj) throws JAXBException { JAXBContext context = JAXBContext.newInstance(clz); Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); StringWriter writer = new StringWriter(); marshaller.marshal(marshalObj, new BufferedWriter(writer)); return writer.toString(); }
From source file:com.autentia.intra.util.BeanUtils.java
/** * Devuelve la pila de una excepcion/*from w w w . jav a 2s .c om*/ * * @param ex la excepcion * @return la pila de la excepcion */ public static String getErrorDesc(Throwable ex) { StringBuffer sb = new StringBuffer(); StringWriter sw = new StringWriter(); ex.printStackTrace(new PrintWriter(sw)); sb.append(sw.toString()); return sb.toString(); }