snipt

Ctrl+h for KB shortcuts

Java

Stream to String

1
2
3
StringWriter writer = new StringWriter();
IOUtils.copy(inputStream, writer, encoding);
String theString = writer.toString();
https://snipt.net/embed/14f145a3a5201607e38146e124cf6585/
/raw/14f145a3a5201607e38146e124cf6585/
14f145a3a5201607e38146e124cf6585
java
Java
3
2019-05-12T03:16:40
True
False
False
/api/public/snipt/40663/
stream-to-string
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="n">StringWriter</span> <span class="n">writer</span> <span class="o">=</span> <span class="k">new</span> <span class="n">StringWriter</span><span class="o">();</span> </span><span id="L-2"><a name="L-2"></a><span class="n">IOUtils</span><span class="o">.</span><span class="na">copy</span><span class="o">(</span><span class="n">inputStream</span><span class="o">,</span> <span class="n">writer</span><span class="o">,</span> <span class="n">encoding</span><span class="o">);</span> </span><span id="L-3"><a name="L-3"></a><span class="n">String</span> <span class="n">theString</span> <span class="o">=</span> <span class="n">writer</span><span class="o">.</span><span class="na">toString</span><span class="o">();</span> </span></pre></div> </td></tr></table>
java, servlet, stream, string, tomcat

Ruby

test chrome

puts testing
https://snipt.net/embed/29763114bd89bf2b9931e0d820aadb60/
/raw/29763114bd89bf2b9931e0d820aadb60/
29763114bd89bf2b9931e0d820aadb60
rb
Ruby
1
2019-04-09T07:20:50
True
False
False
/api/public/snipt/40657/
test-chrome
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nb">puts</span> <span class="n">testing</span> </span></pre></div> </td></tr></table>