ByteArrayOutputStream.html 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <!-- NewPage -->
  3. <html lang="de">
  4. <head>
  5. <!-- Generated by javadoc -->
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  7. <title>ByteArrayOutputStream (Apache Commons IO 2.6 API)</title>
  8. <link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
  9. <script type="text/javascript" src="../../../../../script.js"></script>
  10. </head>
  11. <body>
  12. <script type="text/javascript"><!--
  13. try {
  14. if (location.href.indexOf('is-external=true') == -1) {
  15. parent.document.title="ByteArrayOutputStream (Apache Commons IO 2.6 API)";
  16. }
  17. }
  18. catch(err) {
  19. }
  20. //-->
  21. var methods = {"i0":10,"i1":10,"i2":10,"i3":9,"i4":9,"i5":10,"i6":10,"i7":42,"i8":10,"i9":10,"i10":10,"i11":10,"i12":10,"i13":10};
  22. var tabs = {65535:["t0","All Methods"],1:["t1","Static Methods"],2:["t2","Instance Methods"],8:["t4","Concrete Methods"],32:["t6","Deprecated Methods"]};
  23. var altColor = "altColor";
  24. var rowColor = "rowColor";
  25. var tableTab = "tableTab";
  26. var activeTableTab = "activeTableTab";
  27. </script>
  28. <noscript>
  29. <div>JavaScript is disabled on your browser.</div>
  30. </noscript>
  31. <!-- ========= START OF TOP NAVBAR ======= -->
  32. <div class="topNav"><a name="navbar.top">
  33. <!-- -->
  34. </a>
  35. <div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
  36. <a name="navbar.top.firstrow">
  37. <!-- -->
  38. </a>
  39. <ul class="navList" title="Navigation">
  40. <li><a href="../../../../../overview-summary.html">Overview</a></li>
  41. <li><a href="package-summary.html">Package</a></li>
  42. <li class="navBarCell1Rev">Class</li>
  43. <li><a href="class-use/ByteArrayOutputStream.html">Use</a></li>
  44. <li><a href="package-tree.html">Tree</a></li>
  45. <li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
  46. <li><a href="../../../../../index-all.html">Index</a></li>
  47. <li><a href="../../../../../help-doc.html">Help</a></li>
  48. </ul>
  49. </div>
  50. <div class="subNav">
  51. <ul class="navList">
  52. <li><a href="../../../../../org/apache/commons/io/output/BrokenOutputStream.html" title="class in org.apache.commons.io.output"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
  53. <li><a href="../../../../../org/apache/commons/io/output/ChunkedOutputStream.html" title="class in org.apache.commons.io.output"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
  54. </ul>
  55. <ul class="navList">
  56. <li><a href="../../../../../index.html?org/apache/commons/io/output/ByteArrayOutputStream.html" target="_top">Frames</a></li>
  57. <li><a href="ByteArrayOutputStream.html" target="_top">No&nbsp;Frames</a></li>
  58. </ul>
  59. <ul class="navList" id="allclasses_navbar_top">
  60. <li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
  61. </ul>
  62. <div>
  63. <script type="text/javascript"><!--
  64. allClassesLink = document.getElementById("allclasses_navbar_top");
  65. if(window==top) {
  66. allClassesLink.style.display = "block";
  67. }
  68. else {
  69. allClassesLink.style.display = "none";
  70. }
  71. //-->
  72. </script>
  73. </div>
  74. <div>
  75. <ul class="subNavList">
  76. <li>Summary:&nbsp;</li>
  77. <li>Nested&nbsp;|&nbsp;</li>
  78. <li>Field&nbsp;|&nbsp;</li>
  79. <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
  80. <li><a href="#method.summary">Method</a></li>
  81. </ul>
  82. <ul class="subNavList">
  83. <li>Detail:&nbsp;</li>
  84. <li>Field&nbsp;|&nbsp;</li>
  85. <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
  86. <li><a href="#method.detail">Method</a></li>
  87. </ul>
  88. </div>
  89. <a name="skip.navbar.top">
  90. <!-- -->
  91. </a></div>
  92. <!-- ========= END OF TOP NAVBAR ========= -->
  93. <!-- ======== START OF CLASS DATA ======== -->
  94. <div class="header">
  95. <div class="subTitle">org.apache.commons.io.output</div>
  96. <h2 title="Class ByteArrayOutputStream" class="title">Class ByteArrayOutputStream</h2>
  97. </div>
  98. <div class="contentContainer">
  99. <ul class="inheritance">
  100. <li><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</a></li>
  101. <li>
  102. <ul class="inheritance">
  103. <li><a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">java.io.OutputStream</a></li>
  104. <li>
  105. <ul class="inheritance">
  106. <li>org.apache.commons.io.output.ByteArrayOutputStream</li>
  107. </ul>
  108. </li>
  109. </ul>
  110. </li>
  111. </ul>
  112. <div class="description">
  113. <ul class="blockList">
  114. <li class="blockList">
  115. <dl>
  116. <dt>All Implemented Interfaces:</dt>
  117. <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/io/Flushable.html?is-external=true" title="class or interface in java.io">Flushable</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html?is-external=true" title="class or interface in java.lang">AutoCloseable</a></dd>
  118. </dl>
  119. <hr>
  120. <br>
  121. <pre>public class <span class="typeNameLabel">ByteArrayOutputStream</span>
  122. extends <a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a></pre>
  123. <div class="block">This class implements an output stream in which the data is
  124. written into a byte array. The buffer automatically grows as data
  125. is written to it.
  126. <p>
  127. The data can be retrieved using <code>toByteArray()</code> and
  128. <code>toString()</code>.
  129. <p>
  130. Closing a <code>ByteArrayOutputStream</code> has no effect. The methods in
  131. this class can be called after the stream has been closed without
  132. generating an <code>IOException</code>.
  133. <p>
  134. This is an alternative implementation of the <a href="http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html?is-external=true" title="class or interface in java.io"><code>ByteArrayOutputStream</code></a>
  135. class. The original implementation only allocates 32 bytes at the beginning.
  136. As this class is designed for heavy duty it starts at 1024 bytes. In contrast
  137. to the original it doesn't reallocate the whole memory block but allocates
  138. additional buffers. This way no buffers need to be garbage collected and
  139. the contents don't have to be copied to the new buffer. This class is
  140. designed to behave exactly like the original. The only exception is the
  141. deprecated toString(int) method that has been ignored.</div>
  142. </li>
  143. </ul>
  144. </div>
  145. <div class="summary">
  146. <ul class="blockList">
  147. <li class="blockList">
  148. <!-- ======== CONSTRUCTOR SUMMARY ======== -->
  149. <ul class="blockList">
  150. <li class="blockList"><a name="constructor.summary">
  151. <!-- -->
  152. </a>
  153. <h3>Constructor Summary</h3>
  154. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
  155. <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
  156. <tr>
  157. <th class="colOne" scope="col">Constructor and Description</th>
  158. </tr>
  159. <tr class="altColor">
  160. <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#ByteArrayOutputStream--">ByteArrayOutputStream</a></span>()</code>
  161. <div class="block">Creates a new byte array output stream.</div>
  162. </td>
  163. </tr>
  164. <tr class="rowColor">
  165. <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#ByteArrayOutputStream-int-">ByteArrayOutputStream</a></span>(int&nbsp;size)</code>
  166. <div class="block">Creates a new byte array output stream, with a buffer capacity of
  167. the specified size, in bytes.</div>
  168. </td>
  169. </tr>
  170. </table>
  171. </li>
  172. </ul>
  173. <!-- ========== METHOD SUMMARY =========== -->
  174. <ul class="blockList">
  175. <li class="blockList"><a name="method.summary">
  176. <!-- -->
  177. </a>
  178. <h3>Method Summary</h3>
  179. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
  180. <caption><span id="t0" class="activeTableTab"><span>All Methods</span><span class="tabEnd">&nbsp;</span></span><span id="t1" class="tableTab"><span><a href="javascript:show(1);">Static Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t2" class="tableTab"><span><a href="javascript:show(2);">Instance Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t4" class="tableTab"><span><a href="javascript:show(8);">Concrete Methods</a></span><span class="tabEnd">&nbsp;</span></span><span id="t6" class="tableTab"><span><a href="javascript:show(32);">Deprecated Methods</a></span><span class="tabEnd">&nbsp;</span></span></caption>
  181. <tr>
  182. <th class="colFirst" scope="col">Modifier and Type</th>
  183. <th class="colLast" scope="col">Method and Description</th>
  184. </tr>
  185. <tr id="i0" class="altColor">
  186. <td class="colFirst"><code>void</code></td>
  187. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#close--">close</a></span>()</code>
  188. <div class="block">Closing a <code>ByteArrayOutputStream</code> has no effect.</div>
  189. </td>
  190. </tr>
  191. <tr id="i1" class="rowColor">
  192. <td class="colFirst"><code>void</code></td>
  193. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#reset--">reset</a></span>()</code>&nbsp;</td>
  194. </tr>
  195. <tr id="i2" class="altColor">
  196. <td class="colFirst"><code>int</code></td>
  197. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#size--">size</a></span>()</code>
  198. <div class="block">Return the current size of the byte array.</div>
  199. </td>
  200. </tr>
  201. <tr id="i3" class="rowColor">
  202. <td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a></code></td>
  203. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toBufferedInputStream-java.io.InputStream-">toBufferedInputStream</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;input)</code>
  204. <div class="block">Fetches entire contents of an <code>InputStream</code> and represent
  205. same data as result InputStream.</div>
  206. </td>
  207. </tr>
  208. <tr id="i4" class="altColor">
  209. <td class="colFirst"><code>static <a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a></code></td>
  210. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toBufferedInputStream-java.io.InputStream-int-">toBufferedInputStream</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;input,
  211. int&nbsp;size)</code>
  212. <div class="block">Fetches entire contents of an <code>InputStream</code> and represent
  213. same data as result InputStream.</div>
  214. </td>
  215. </tr>
  216. <tr id="i5" class="rowColor">
  217. <td class="colFirst"><code>byte[]</code></td>
  218. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toByteArray--">toByteArray</a></span>()</code>
  219. <div class="block">Gets the current contents of this byte stream as a byte array.</div>
  220. </td>
  221. </tr>
  222. <tr id="i6" class="altColor">
  223. <td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a></code></td>
  224. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toInputStream--">toInputStream</a></span>()</code>
  225. <div class="block">Gets the current contents of this byte stream as a Input Stream.</div>
  226. </td>
  227. </tr>
  228. <tr id="i7" class="rowColor">
  229. <td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
  230. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toString--">toString</a></span>()</code>
  231. <div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;
  232. <div class="block"><span class="deprecationComment">2.5 use <a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toString-java.lang.String-"><code>toString(String)</code></a> instead</span></div>
  233. </div>
  234. </td>
  235. </tr>
  236. <tr id="i8" class="altColor">
  237. <td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
  238. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toString-java.nio.charset.Charset-">toString</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</a>&nbsp;charset)</code>
  239. <div class="block">Gets the current contents of this byte stream as a string
  240. using the specified encoding.</div>
  241. </td>
  242. </tr>
  243. <tr id="i9" class="rowColor">
  244. <td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a></code></td>
  245. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toString-java.lang.String-">toString</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;enc)</code>
  246. <div class="block">Gets the current contents of this byte stream as a string
  247. using the specified encoding.</div>
  248. </td>
  249. </tr>
  250. <tr id="i10" class="altColor">
  251. <td class="colFirst"><code>void</code></td>
  252. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#write-byte:A-int-int-">write</a></span>(byte[]&nbsp;b,
  253. int&nbsp;off,
  254. int&nbsp;len)</code>
  255. <div class="block">Write the bytes to byte array.</div>
  256. </td>
  257. </tr>
  258. <tr id="i11" class="rowColor">
  259. <td class="colFirst"><code>int</code></td>
  260. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#write-java.io.InputStream-">write</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;in)</code>
  261. <div class="block">Writes the entire contents of the specified input stream to this
  262. byte stream.</div>
  263. </td>
  264. </tr>
  265. <tr id="i12" class="altColor">
  266. <td class="colFirst"><code>void</code></td>
  267. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#write-int-">write</a></span>(int&nbsp;b)</code>
  268. <div class="block">Write a byte to byte array.</div>
  269. </td>
  270. </tr>
  271. <tr id="i13" class="rowColor">
  272. <td class="colFirst"><code>void</code></td>
  273. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#writeTo-java.io.OutputStream-">writeTo</a></span>(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a>&nbsp;out)</code>
  274. <div class="block">Writes the entire contents of this byte stream to the
  275. specified output stream.</div>
  276. </td>
  277. </tr>
  278. </table>
  279. <ul class="blockList">
  280. <li class="blockList"><a name="methods.inherited.from.class.java.io.OutputStream">
  281. <!-- -->
  282. </a>
  283. <h3>Methods inherited from class&nbsp;java.io.<a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a></h3>
  284. <code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true#flush--" title="class or interface in java.io">flush</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true#write-byte:A-" title="class or interface in java.io">write</a></code></li>
  285. </ul>
  286. <ul class="blockList">
  287. <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
  288. <!-- -->
  289. </a>
  290. <h3>Methods inherited from class&nbsp;java.lang.<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></h3>
  291. <code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#clone--" title="class or interface in java.lang">clone</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#equals-java.lang.Object-" title="class or interface in java.lang">equals</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#finalize--" title="class or interface in java.lang">finalize</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#getClass--" title="class or interface in java.lang">getClass</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#hashCode--" title="class or interface in java.lang">hashCode</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notify--" title="class or interface in java.lang">notify</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#notifyAll--" title="class or interface in java.lang">notifyAll</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait--" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-" title="class or interface in java.lang">wait</a>, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#wait-long-int-" title="class or interface in java.lang">wait</a></code></li>
  292. </ul>
  293. </li>
  294. </ul>
  295. </li>
  296. </ul>
  297. </div>
  298. <div class="details">
  299. <ul class="blockList">
  300. <li class="blockList">
  301. <!-- ========= CONSTRUCTOR DETAIL ======== -->
  302. <ul class="blockList">
  303. <li class="blockList"><a name="constructor.detail">
  304. <!-- -->
  305. </a>
  306. <h3>Constructor Detail</h3>
  307. <a name="ByteArrayOutputStream--">
  308. <!-- -->
  309. </a>
  310. <ul class="blockList">
  311. <li class="blockList">
  312. <h4>ByteArrayOutputStream</h4>
  313. <pre>public&nbsp;ByteArrayOutputStream()</pre>
  314. <div class="block">Creates a new byte array output stream. The buffer capacity is
  315. initially 1024 bytes, though its size increases if necessary.</div>
  316. </li>
  317. </ul>
  318. <a name="ByteArrayOutputStream-int-">
  319. <!-- -->
  320. </a>
  321. <ul class="blockListLast">
  322. <li class="blockList">
  323. <h4>ByteArrayOutputStream</h4>
  324. <pre>public&nbsp;ByteArrayOutputStream(int&nbsp;size)</pre>
  325. <div class="block">Creates a new byte array output stream, with a buffer capacity of
  326. the specified size, in bytes.</div>
  327. <dl>
  328. <dt><span class="paramLabel">Parameters:</span></dt>
  329. <dd><code>size</code> - the initial size</dd>
  330. <dt><span class="throwsLabel">Throws:</span></dt>
  331. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</a></code> - if size is negative</dd>
  332. </dl>
  333. </li>
  334. </ul>
  335. </li>
  336. </ul>
  337. <!-- ============ METHOD DETAIL ========== -->
  338. <ul class="blockList">
  339. <li class="blockList"><a name="method.detail">
  340. <!-- -->
  341. </a>
  342. <h3>Method Detail</h3>
  343. <a name="write-byte:A-int-int-">
  344. <!-- -->
  345. </a>
  346. <ul class="blockList">
  347. <li class="blockList">
  348. <h4>write</h4>
  349. <pre>public&nbsp;void&nbsp;write(byte[]&nbsp;b,
  350. int&nbsp;off,
  351. int&nbsp;len)</pre>
  352. <div class="block">Write the bytes to byte array.</div>
  353. <dl>
  354. <dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
  355. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true#write-byte:A-int-int-" title="class or interface in java.io">write</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a></code></dd>
  356. <dt><span class="paramLabel">Parameters:</span></dt>
  357. <dd><code>b</code> - the bytes to write</dd>
  358. <dd><code>off</code> - The start offset</dd>
  359. <dd><code>len</code> - The number of bytes to write</dd>
  360. </dl>
  361. </li>
  362. </ul>
  363. <a name="write-int-">
  364. <!-- -->
  365. </a>
  366. <ul class="blockList">
  367. <li class="blockList">
  368. <h4>write</h4>
  369. <pre>public&nbsp;void&nbsp;write(int&nbsp;b)</pre>
  370. <div class="block">Write a byte to byte array.</div>
  371. <dl>
  372. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  373. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true#write-int-" title="class or interface in java.io">write</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a></code></dd>
  374. <dt><span class="paramLabel">Parameters:</span></dt>
  375. <dd><code>b</code> - the byte to write</dd>
  376. </dl>
  377. </li>
  378. </ul>
  379. <a name="write-java.io.InputStream-">
  380. <!-- -->
  381. </a>
  382. <ul class="blockList">
  383. <li class="blockList">
  384. <h4>write</h4>
  385. <pre>public&nbsp;int&nbsp;write(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;in)
  386. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  387. <div class="block">Writes the entire contents of the specified input stream to this
  388. byte stream. Bytes from the input stream are read directly into the
  389. internal buffers of this streams.</div>
  390. <dl>
  391. <dt><span class="paramLabel">Parameters:</span></dt>
  392. <dd><code>in</code> - the input stream to read from</dd>
  393. <dt><span class="returnLabel">Returns:</span></dt>
  394. <dd>total number of bytes read from the input stream
  395. (and written to this stream)</dd>
  396. <dt><span class="throwsLabel">Throws:</span></dt>
  397. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O error occurs while reading the input stream</dd>
  398. <dt><span class="simpleTagLabel">Since:</span></dt>
  399. <dd>1.4</dd>
  400. </dl>
  401. </li>
  402. </ul>
  403. <a name="size--">
  404. <!-- -->
  405. </a>
  406. <ul class="blockList">
  407. <li class="blockList">
  408. <h4>size</h4>
  409. <pre>public&nbsp;int&nbsp;size()</pre>
  410. <div class="block">Return the current size of the byte array.</div>
  411. <dl>
  412. <dt><span class="returnLabel">Returns:</span></dt>
  413. <dd>the current size of the byte array</dd>
  414. </dl>
  415. </li>
  416. </ul>
  417. <a name="close--">
  418. <!-- -->
  419. </a>
  420. <ul class="blockList">
  421. <li class="blockList">
  422. <h4>close</h4>
  423. <pre>public&nbsp;void&nbsp;close()
  424. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  425. <div class="block">Closing a <code>ByteArrayOutputStream</code> has no effect. The methods in
  426. this class can be called after the stream has been closed without
  427. generating an <code>IOException</code>.</div>
  428. <dl>
  429. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  430. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html?is-external=true#close--" title="class or interface in java.io">close</a></code>&nbsp;in interface&nbsp;<code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</a></code></dd>
  431. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  432. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html?is-external=true#close--" title="class or interface in java.lang">close</a></code>&nbsp;in interface&nbsp;<code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/AutoCloseable.html?is-external=true" title="class or interface in java.lang">AutoCloseable</a></code></dd>
  433. <dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
  434. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true#close--" title="class or interface in java.io">close</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a></code></dd>
  435. <dt><span class="throwsLabel">Throws:</span></dt>
  436. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - never (this method should not declare this exception
  437. but it has to now due to backwards compatibility)</dd>
  438. </dl>
  439. </li>
  440. </ul>
  441. <a name="reset--">
  442. <!-- -->
  443. </a>
  444. <ul class="blockList">
  445. <li class="blockList">
  446. <h4>reset</h4>
  447. <pre>public&nbsp;void&nbsp;reset()</pre>
  448. <dl>
  449. <dt><span class="seeLabel">See Also:</span></dt>
  450. <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html?is-external=true#reset--" title="class or interface in java.io"><code>ByteArrayOutputStream.reset()</code></a></dd>
  451. </dl>
  452. </li>
  453. </ul>
  454. <a name="writeTo-java.io.OutputStream-">
  455. <!-- -->
  456. </a>
  457. <ul class="blockList">
  458. <li class="blockList">
  459. <h4>writeTo</h4>
  460. <pre>public&nbsp;void&nbsp;writeTo(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</a>&nbsp;out)
  461. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  462. <div class="block">Writes the entire contents of this byte stream to the
  463. specified output stream.</div>
  464. <dl>
  465. <dt><span class="paramLabel">Parameters:</span></dt>
  466. <dd><code>out</code> - the output stream to write to</dd>
  467. <dt><span class="throwsLabel">Throws:</span></dt>
  468. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O error occurs, such as if the stream is closed</dd>
  469. <dt><span class="seeLabel">See Also:</span></dt>
  470. <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html?is-external=true#writeTo-java.io.OutputStream-" title="class or interface in java.io"><code>ByteArrayOutputStream.writeTo(OutputStream)</code></a></dd>
  471. </dl>
  472. </li>
  473. </ul>
  474. <a name="toBufferedInputStream-java.io.InputStream-">
  475. <!-- -->
  476. </a>
  477. <ul class="blockList">
  478. <li class="blockList">
  479. <h4>toBufferedInputStream</h4>
  480. <pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;toBufferedInputStream(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;input)
  481. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  482. <div class="block">Fetches entire contents of an <code>InputStream</code> and represent
  483. same data as result InputStream.
  484. <p>
  485. This method is useful where,
  486. <ul>
  487. <li>Source InputStream is slow.</li>
  488. <li>It has network resources associated, so we cannot keep it open for
  489. long time.</li>
  490. <li>It has network timeout associated.</li>
  491. </ul>
  492. It can be used in favor of <a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toByteArray--"><code>toByteArray()</code></a>, since it
  493. avoids unnecessary allocation and copy of byte[].<br>
  494. This method buffers the input internally, so there is no need to use a
  495. <code>BufferedInputStream</code>.</div>
  496. <dl>
  497. <dt><span class="paramLabel">Parameters:</span></dt>
  498. <dd><code>input</code> - Stream to be fully buffered.</dd>
  499. <dt><span class="returnLabel">Returns:</span></dt>
  500. <dd>A fully buffered stream.</dd>
  501. <dt><span class="throwsLabel">Throws:</span></dt>
  502. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O error occurs</dd>
  503. <dt><span class="simpleTagLabel">Since:</span></dt>
  504. <dd>2.0</dd>
  505. </dl>
  506. </li>
  507. </ul>
  508. <a name="toBufferedInputStream-java.io.InputStream-int-">
  509. <!-- -->
  510. </a>
  511. <ul class="blockList">
  512. <li class="blockList">
  513. <h4>toBufferedInputStream</h4>
  514. <pre>public static&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;toBufferedInputStream(<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;input,
  515. int&nbsp;size)
  516. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></pre>
  517. <div class="block">Fetches entire contents of an <code>InputStream</code> and represent
  518. same data as result InputStream.
  519. <p>
  520. This method is useful where,
  521. <ul>
  522. <li>Source InputStream is slow.</li>
  523. <li>It has network resources associated, so we cannot keep it open for
  524. long time.</li>
  525. <li>It has network timeout associated.</li>
  526. </ul>
  527. It can be used in favor of <a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toByteArray--"><code>toByteArray()</code></a>, since it
  528. avoids unnecessary allocation and copy of byte[].<br>
  529. This method buffers the input internally, so there is no need to use a
  530. <code>BufferedInputStream</code>.</div>
  531. <dl>
  532. <dt><span class="paramLabel">Parameters:</span></dt>
  533. <dd><code>input</code> - Stream to be fully buffered.</dd>
  534. <dd><code>size</code> - the initial buffer size</dd>
  535. <dt><span class="returnLabel">Returns:</span></dt>
  536. <dd>A fully buffered stream.</dd>
  537. <dt><span class="throwsLabel">Throws:</span></dt>
  538. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</a></code> - if an I/O error occurs</dd>
  539. <dt><span class="simpleTagLabel">Since:</span></dt>
  540. <dd>2.5</dd>
  541. </dl>
  542. </li>
  543. </ul>
  544. <a name="toInputStream--">
  545. <!-- -->
  546. </a>
  547. <ul class="blockList">
  548. <li class="blockList">
  549. <h4>toInputStream</h4>
  550. <pre>public&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</a>&nbsp;toInputStream()</pre>
  551. <div class="block">Gets the current contents of this byte stream as a Input Stream. The
  552. returned stream is backed by buffers of <code>this</code> stream,
  553. avoiding memory allocation and copy, thus saving space and time.<br></div>
  554. <dl>
  555. <dt><span class="returnLabel">Returns:</span></dt>
  556. <dd>the current contents of this output stream.</dd>
  557. <dt><span class="simpleTagLabel">Since:</span></dt>
  558. <dd>2.5</dd>
  559. <dt><span class="seeLabel">See Also:</span></dt>
  560. <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html?is-external=true#toByteArray--" title="class or interface in java.io"><code>ByteArrayOutputStream.toByteArray()</code></a>,
  561. <a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#reset--"><code>reset()</code></a></dd>
  562. </dl>
  563. </li>
  564. </ul>
  565. <a name="toByteArray--">
  566. <!-- -->
  567. </a>
  568. <ul class="blockList">
  569. <li class="blockList">
  570. <h4>toByteArray</h4>
  571. <pre>public&nbsp;byte[]&nbsp;toByteArray()</pre>
  572. <div class="block">Gets the current contents of this byte stream as a byte array.
  573. The result is independent of this stream.</div>
  574. <dl>
  575. <dt><span class="returnLabel">Returns:</span></dt>
  576. <dd>the current contents of this output stream, as a byte array</dd>
  577. <dt><span class="seeLabel">See Also:</span></dt>
  578. <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html?is-external=true#toByteArray--" title="class or interface in java.io"><code>ByteArrayOutputStream.toByteArray()</code></a></dd>
  579. </dl>
  580. </li>
  581. </ul>
  582. <a name="toString--">
  583. <!-- -->
  584. </a>
  585. <ul class="blockList">
  586. <li class="blockList">
  587. <h4>toString</h4>
  588. <pre><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Deprecated.html?is-external=true" title="class or interface in java.lang">@Deprecated</a>
  589. public&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;toString()</pre>
  590. <div class="block"><span class="deprecatedLabel">Deprecated.</span>&nbsp;<span class="deprecationComment">2.5 use <a href="../../../../../org/apache/commons/io/output/ByteArrayOutputStream.html#toString-java.lang.String-"><code>toString(String)</code></a> instead</span></div>
  591. <div class="block">Gets the current contents of this byte stream as a string
  592. using the platform default charset.</div>
  593. <dl>
  594. <dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
  595. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true#toString--" title="class or interface in java.lang">toString</a></code>&nbsp;in class&nbsp;<code><a href="http://docs.oracle.com/javase/7/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</a></code></dd>
  596. <dt><span class="returnLabel">Returns:</span></dt>
  597. <dd>the contents of the byte array as a String</dd>
  598. <dt><span class="seeLabel">See Also:</span></dt>
  599. <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html?is-external=true#toString--" title="class or interface in java.io"><code>ByteArrayOutputStream.toString()</code></a></dd>
  600. </dl>
  601. </li>
  602. </ul>
  603. <a name="toString-java.lang.String-">
  604. <!-- -->
  605. </a>
  606. <ul class="blockList">
  607. <li class="blockList">
  608. <h4>toString</h4>
  609. <pre>public&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;toString(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;enc)
  610. throws <a href="http://docs.oracle.com/javase/7/docs/api/java/io/UnsupportedEncodingException.html?is-external=true" title="class or interface in java.io">UnsupportedEncodingException</a></pre>
  611. <div class="block">Gets the current contents of this byte stream as a string
  612. using the specified encoding.</div>
  613. <dl>
  614. <dt><span class="paramLabel">Parameters:</span></dt>
  615. <dd><code>enc</code> - the name of the character encoding</dd>
  616. <dt><span class="returnLabel">Returns:</span></dt>
  617. <dd>the string converted from the byte array</dd>
  618. <dt><span class="throwsLabel">Throws:</span></dt>
  619. <dd><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/UnsupportedEncodingException.html?is-external=true" title="class or interface in java.io">UnsupportedEncodingException</a></code> - if the encoding is not supported</dd>
  620. <dt><span class="seeLabel">See Also:</span></dt>
  621. <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html?is-external=true#toString-java.lang.String-" title="class or interface in java.io"><code>ByteArrayOutputStream.toString(String)</code></a></dd>
  622. </dl>
  623. </li>
  624. </ul>
  625. <a name="toString-java.nio.charset.Charset-">
  626. <!-- -->
  627. </a>
  628. <ul class="blockListLast">
  629. <li class="blockList">
  630. <h4>toString</h4>
  631. <pre>public&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</a>&nbsp;toString(<a href="http://docs.oracle.com/javase/7/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</a>&nbsp;charset)</pre>
  632. <div class="block">Gets the current contents of this byte stream as a string
  633. using the specified encoding.</div>
  634. <dl>
  635. <dt><span class="paramLabel">Parameters:</span></dt>
  636. <dd><code>charset</code> - the character encoding</dd>
  637. <dt><span class="returnLabel">Returns:</span></dt>
  638. <dd>the string converted from the byte array</dd>
  639. <dt><span class="simpleTagLabel">Since:</span></dt>
  640. <dd>2.5</dd>
  641. <dt><span class="seeLabel">See Also:</span></dt>
  642. <dd><a href="http://docs.oracle.com/javase/7/docs/api/java/io/ByteArrayOutputStream.html?is-external=true#toString-java.lang.String-" title="class or interface in java.io"><code>ByteArrayOutputStream.toString(String)</code></a></dd>
  643. </dl>
  644. </li>
  645. </ul>
  646. </li>
  647. </ul>
  648. </li>
  649. </ul>
  650. </div>
  651. </div>
  652. <!-- ========= END OF CLASS DATA ========= -->
  653. <!-- ======= START OF BOTTOM NAVBAR ====== -->
  654. <div class="bottomNav"><a name="navbar.bottom">
  655. <!-- -->
  656. </a>
  657. <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
  658. <a name="navbar.bottom.firstrow">
  659. <!-- -->
  660. </a>
  661. <ul class="navList" title="Navigation">
  662. <li><a href="../../../../../overview-summary.html">Overview</a></li>
  663. <li><a href="package-summary.html">Package</a></li>
  664. <li class="navBarCell1Rev">Class</li>
  665. <li><a href="class-use/ByteArrayOutputStream.html">Use</a></li>
  666. <li><a href="package-tree.html">Tree</a></li>
  667. <li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
  668. <li><a href="../../../../../index-all.html">Index</a></li>
  669. <li><a href="../../../../../help-doc.html">Help</a></li>
  670. </ul>
  671. </div>
  672. <div class="subNav">
  673. <ul class="navList">
  674. <li><a href="../../../../../org/apache/commons/io/output/BrokenOutputStream.html" title="class in org.apache.commons.io.output"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
  675. <li><a href="../../../../../org/apache/commons/io/output/ChunkedOutputStream.html" title="class in org.apache.commons.io.output"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
  676. </ul>
  677. <ul class="navList">
  678. <li><a href="../../../../../index.html?org/apache/commons/io/output/ByteArrayOutputStream.html" target="_top">Frames</a></li>
  679. <li><a href="ByteArrayOutputStream.html" target="_top">No&nbsp;Frames</a></li>
  680. </ul>
  681. <ul class="navList" id="allclasses_navbar_bottom">
  682. <li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
  683. </ul>
  684. <div>
  685. <script type="text/javascript"><!--
  686. allClassesLink = document.getElementById("allclasses_navbar_bottom");
  687. if(window==top) {
  688. allClassesLink.style.display = "block";
  689. }
  690. else {
  691. allClassesLink.style.display = "none";
  692. }
  693. //-->
  694. </script>
  695. </div>
  696. <div>
  697. <ul class="subNavList">
  698. <li>Summary:&nbsp;</li>
  699. <li>Nested&nbsp;|&nbsp;</li>
  700. <li>Field&nbsp;|&nbsp;</li>
  701. <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
  702. <li><a href="#method.summary">Method</a></li>
  703. </ul>
  704. <ul class="subNavList">
  705. <li>Detail:&nbsp;</li>
  706. <li>Field&nbsp;|&nbsp;</li>
  707. <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
  708. <li><a href="#method.detail">Method</a></li>
  709. </ul>
  710. </div>
  711. <a name="skip.navbar.bottom">
  712. <!-- -->
  713. </a></div>
  714. <!-- ======== END OF BOTTOM NAVBAR ======= -->
  715. <p class="legalCopy"><small>Copyright &#169; 2002&#x2013;2017 <a href="https://www.apache.org/">The Apache Software Foundation</a>. All rights reserved.</small></p>
  716. </body>
  717. </html>