/** * Encodes any invalid XML element name characters to <code>_x####_</code> sequences. * * @param o The object being encoded. * @return The encoded element name string. */ public static final String encodeElementName(Object o) { if (o == null) return "_x0000_"; String s = o.toString(); if (s.isEmpty()) return "_xE000_"; try { if (needsElementNameEncoding(s)) try (Writer w = new StringBuilderWriter(s.length() * 2)) { return encodeElementNameInner(w, s).toString(); } } catch (IOException e) { throw new RuntimeException(e); // Never happens } return s; }
/** * Encodes any invalid XML element name characters to <code>_x####_</code> sequences. * * @param o The object being encoded. * @return The encoded element name string. */ public static final String encodeElementName(Object o) { if (o == null) return "_x0000_"; String s = o.toString(); if (s.isEmpty()) return "_xE000_"; try { if (needsElementNameEncoding(s)) try (Writer w = new StringBuilderWriter(s.length() * 2)) { return encodeElementNameInner(w, s).toString(); } } catch (IOException e) { throw new RuntimeException(e); // Never happens } return s; }
writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream((File)output))); else if (output instanceof StringBuilder) writer = new StringBuilderWriter((StringBuilder)output); else throw new IOException("Cannot convert object of type "+output.getClass().getName()+" to a Writer.");
/** * Encodes any invalid XML element name characters to <code>_x####_</code> sequences. * * @param o The object being encoded. * @return The encoded element name string. */ public static final String encodeElementName(Object o) { if (o == null) return "_x0000_"; String s = o.toString(); if (s.isEmpty()) return "_xE000_"; try { if (needsElementNameEncoding(s)) try (Writer w = new StringBuilderWriter(s.length() * 2)) { return encodeElementNameInner(w, s).toString(); } } catch (IOException e) { throw new RuntimeException(e); // Never happens } return s; }
writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream((File)output))); else if (output instanceof StringBuilder) writer = new StringBuilderWriter((StringBuilder)output); else throw new IOException("Cannot convert object of type "+output.getClass().getName()+" to a Writer.");
writer = new OutputStreamWriter(new BufferedOutputStream(new FileOutputStream((File)output))); else if (output instanceof StringBuilder) writer = new StringBuilderWriter((StringBuilder)output); else throw new IOException("Cannot convert object of type "+output.getClass().getName()+" to a Writer.");
Object o = getContent(req); if (o instanceof Reader) { try (Reader r = (Reader)o; Writer w = new StringBuilderWriter(sb)) { IOUtils.pipe(r, w);
Object o = getContent(req); if (o instanceof Reader) { try (Reader r = (Reader)o; Writer w = new StringBuilderWriter(sb)) { IOUtils.pipe(r, w);
Object o = getContent(req); if (o instanceof Reader) { try (Reader r = (Reader)o; Writer w = new StringBuilderWriter(sb)) { IOUtils.pipe(r, w);
@Test public void test() throws Exception { StringBuilderWriter sbw = new StringBuilderWriter(); sbw.write("abc"); assertEquals("abc", sbw.toString()); sbw = new StringBuilderWriter(); sbw.write(buff, 0, buff.length); assertEquals("abc", sbw.toString());