DeferredFileOutputStream.html 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581
  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>DeferredFileOutputStream (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="DeferredFileOutputStream (Apache Commons IO 2.6 API)";
  16. }
  17. }
  18. catch(err) {
  19. }
  20. //-->
  21. var methods = {"i0":10,"i1":10,"i2":10,"i3":10,"i4":10,"i5":10,"i6":10};
  22. var tabs = {65535:["t0","All Methods"],2:["t2","Instance Methods"],8:["t4","Concrete 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/DeferredFileOutputStream.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/CountingOutputStream.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/DemuxOutputStream.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/DeferredFileOutputStream.html" target="_top">Frames</a></li>
  57. <li><a href="DeferredFileOutputStream.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 DeferredFileOutputStream" class="title">Class DeferredFileOutputStream</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><a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html" title="class in org.apache.commons.io.output">org.apache.commons.io.output.ThresholdingOutputStream</a></li>
  107. <li>
  108. <ul class="inheritance">
  109. <li>org.apache.commons.io.output.DeferredFileOutputStream</li>
  110. </ul>
  111. </li>
  112. </ul>
  113. </li>
  114. </ul>
  115. </li>
  116. </ul>
  117. <div class="description">
  118. <ul class="blockList">
  119. <li class="blockList">
  120. <dl>
  121. <dt>All Implemented Interfaces:</dt>
  122. <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>
  123. </dl>
  124. <hr>
  125. <br>
  126. <pre>public class <span class="typeNameLabel">DeferredFileOutputStream</span>
  127. extends <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html" title="class in org.apache.commons.io.output">ThresholdingOutputStream</a></pre>
  128. <div class="block">An output stream which will retain data in memory until a specified
  129. threshold is reached, and only then commit it to disk. If the stream is
  130. closed before the threshold is reached, the data will not be written to
  131. disk at all.
  132. <p>
  133. This class originated in FileUpload processing. In this use case, you do
  134. not know in advance the size of the file being uploaded. If the file is small
  135. you want to store it in memory (for speed), but if the file is large you want
  136. to store it to file (to avoid memory issues).</div>
  137. </li>
  138. </ul>
  139. </div>
  140. <div class="summary">
  141. <ul class="blockList">
  142. <li class="blockList">
  143. <!-- ======== CONSTRUCTOR SUMMARY ======== -->
  144. <ul class="blockList">
  145. <li class="blockList"><a name="constructor.summary">
  146. <!-- -->
  147. </a>
  148. <h3>Constructor Summary</h3>
  149. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Constructor Summary table, listing constructors, and an explanation">
  150. <caption><span>Constructors</span><span class="tabEnd">&nbsp;</span></caption>
  151. <tr>
  152. <th class="colOne" scope="col">Constructor and Description</th>
  153. </tr>
  154. <tr class="altColor">
  155. <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#DeferredFileOutputStream-int-java.io.File-">DeferredFileOutputStream</a></span>(int&nbsp;threshold,
  156. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;outputFile)</code>
  157. <div class="block">Constructs an instance of this class which will trigger an event at the
  158. specified threshold, and save data to a file beyond that point.</div>
  159. </td>
  160. </tr>
  161. <tr class="rowColor">
  162. <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#DeferredFileOutputStream-int-int-java.io.File-">DeferredFileOutputStream</a></span>(int&nbsp;threshold,
  163. int&nbsp;initialBufferSize,
  164. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;outputFile)</code>
  165. <div class="block">Constructs an instance of this class which will trigger an event at the
  166. specified threshold, and save data to a file beyond that point.</div>
  167. </td>
  168. </tr>
  169. <tr class="altColor">
  170. <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#DeferredFileOutputStream-int-int-java.lang.String-java.lang.String-java.io.File-">DeferredFileOutputStream</a></span>(int&nbsp;threshold,
  171. int&nbsp;initialBufferSize,
  172. <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;prefix,
  173. <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;suffix,
  174. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory)</code>
  175. <div class="block">Constructs an instance of this class which will trigger an event at the
  176. specified threshold, and save data to a temporary file beyond that point.</div>
  177. </td>
  178. </tr>
  179. <tr class="rowColor">
  180. <td class="colOne"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#DeferredFileOutputStream-int-java.lang.String-java.lang.String-java.io.File-">DeferredFileOutputStream</a></span>(int&nbsp;threshold,
  181. <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;prefix,
  182. <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;suffix,
  183. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory)</code>
  184. <div class="block">Constructs an instance of this class which will trigger an event at the
  185. specified threshold, and save data to a temporary file beyond that point.</div>
  186. </td>
  187. </tr>
  188. </table>
  189. </li>
  190. </ul>
  191. <!-- ========== METHOD SUMMARY =========== -->
  192. <ul class="blockList">
  193. <li class="blockList"><a name="method.summary">
  194. <!-- -->
  195. </a>
  196. <h3>Method Summary</h3>
  197. <table class="memberSummary" border="0" cellpadding="3" cellspacing="0" summary="Method Summary table, listing methods, and an explanation">
  198. <caption><span id="t0" class="activeTableTab"><span>All Methods</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></caption>
  199. <tr>
  200. <th class="colFirst" scope="col">Modifier and Type</th>
  201. <th class="colLast" scope="col">Method and Description</th>
  202. </tr>
  203. <tr id="i0" class="altColor">
  204. <td class="colFirst"><code>void</code></td>
  205. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#close--">close</a></span>()</code>
  206. <div class="block">Closes underlying output stream, and mark this as closed</div>
  207. </td>
  208. </tr>
  209. <tr id="i1" class="rowColor">
  210. <td class="colFirst"><code>byte[]</code></td>
  211. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#getData--">getData</a></span>()</code>
  212. <div class="block">Returns the data for this output stream as an array of bytes, assuming
  213. that the data has been retained in memory.</div>
  214. </td>
  215. </tr>
  216. <tr id="i2" class="altColor">
  217. <td class="colFirst"><code><a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a></code></td>
  218. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#getFile--">getFile</a></span>()</code>
  219. <div class="block">Returns either the output file specified in the constructor or
  220. the temporary file created or null.</div>
  221. </td>
  222. </tr>
  223. <tr id="i3" class="rowColor">
  224. <td class="colFirst"><code>protected <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></td>
  225. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#getStream--">getStream</a></span>()</code>
  226. <div class="block">Returns the current output stream.</div>
  227. </td>
  228. </tr>
  229. <tr id="i4" class="altColor">
  230. <td class="colFirst"><code>boolean</code></td>
  231. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#isInMemory--">isInMemory</a></span>()</code>
  232. <div class="block">Determines whether or not the data for this output stream has been
  233. retained in memory.</div>
  234. </td>
  235. </tr>
  236. <tr id="i5" class="rowColor">
  237. <td class="colFirst"><code>protected void</code></td>
  238. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.html#thresholdReached--">thresholdReached</a></span>()</code>
  239. <div class="block">Switches the underlying output stream from a memory based stream to one
  240. that is backed by disk.</div>
  241. </td>
  242. </tr>
  243. <tr id="i6" class="altColor">
  244. <td class="colFirst"><code>void</code></td>
  245. <td class="colLast"><code><span class="memberNameLink"><a href="../../../../../org/apache/commons/io/output/DeferredFileOutputStream.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>
  246. <div class="block">Writes the data from this output stream to the specified output stream,
  247. after it has been closed.</div>
  248. </td>
  249. </tr>
  250. </table>
  251. <ul class="blockList">
  252. <li class="blockList"><a name="methods.inherited.from.class.org.apache.commons.io.output.ThresholdingOutputStream">
  253. <!-- -->
  254. </a>
  255. <h3>Methods inherited from class&nbsp;org.apache.commons.io.output.<a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html" title="class in org.apache.commons.io.output">ThresholdingOutputStream</a></h3>
  256. <code><a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#checkThreshold-int-">checkThreshold</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#flush--">flush</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#getByteCount--">getByteCount</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#getThreshold--">getThreshold</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#isThresholdExceeded--">isThresholdExceeded</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#resetByteCount--">resetByteCount</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#setByteCount-long-">setByteCount</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#write-byte:A-">write</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#write-byte:A-int-int-">write</a>, <a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#write-int-">write</a></code></li>
  257. </ul>
  258. <ul class="blockList">
  259. <li class="blockList"><a name="methods.inherited.from.class.java.lang.Object">
  260. <!-- -->
  261. </a>
  262. <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>
  263. <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#toString--" title="class or interface in java.lang">toString</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>
  264. </ul>
  265. </li>
  266. </ul>
  267. </li>
  268. </ul>
  269. </div>
  270. <div class="details">
  271. <ul class="blockList">
  272. <li class="blockList">
  273. <!-- ========= CONSTRUCTOR DETAIL ======== -->
  274. <ul class="blockList">
  275. <li class="blockList"><a name="constructor.detail">
  276. <!-- -->
  277. </a>
  278. <h3>Constructor Detail</h3>
  279. <a name="DeferredFileOutputStream-int-java.io.File-">
  280. <!-- -->
  281. </a>
  282. <ul class="blockList">
  283. <li class="blockList">
  284. <h4>DeferredFileOutputStream</h4>
  285. <pre>public&nbsp;DeferredFileOutputStream(int&nbsp;threshold,
  286. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;outputFile)</pre>
  287. <div class="block">Constructs an instance of this class which will trigger an event at the
  288. specified threshold, and save data to a file beyond that point.
  289. The initial buffer size will default to 1024 bytes which is ByteArrayOutputStream's default buffer size.</div>
  290. <dl>
  291. <dt><span class="paramLabel">Parameters:</span></dt>
  292. <dd><code>threshold</code> - The number of bytes at which to trigger an event.</dd>
  293. <dd><code>outputFile</code> - The file to which data is saved beyond the threshold.</dd>
  294. </dl>
  295. </li>
  296. </ul>
  297. <a name="DeferredFileOutputStream-int-int-java.io.File-">
  298. <!-- -->
  299. </a>
  300. <ul class="blockList">
  301. <li class="blockList">
  302. <h4>DeferredFileOutputStream</h4>
  303. <pre>public&nbsp;DeferredFileOutputStream(int&nbsp;threshold,
  304. int&nbsp;initialBufferSize,
  305. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;outputFile)</pre>
  306. <div class="block">Constructs an instance of this class which will trigger an event at the
  307. specified threshold, and save data to a file beyond that point.</div>
  308. <dl>
  309. <dt><span class="paramLabel">Parameters:</span></dt>
  310. <dd><code>threshold</code> - The number of bytes at which to trigger an event.</dd>
  311. <dd><code>initialBufferSize</code> - The initial size of the in memory buffer.</dd>
  312. <dd><code>outputFile</code> - The file to which data is saved beyond the threshold.</dd>
  313. <dt><span class="simpleTagLabel">Since:</span></dt>
  314. <dd>2.5</dd>
  315. </dl>
  316. </li>
  317. </ul>
  318. <a name="DeferredFileOutputStream-int-java.lang.String-java.lang.String-java.io.File-">
  319. <!-- -->
  320. </a>
  321. <ul class="blockList">
  322. <li class="blockList">
  323. <h4>DeferredFileOutputStream</h4>
  324. <pre>public&nbsp;DeferredFileOutputStream(int&nbsp;threshold,
  325. <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;prefix,
  326. <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;suffix,
  327. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory)</pre>
  328. <div class="block">Constructs an instance of this class which will trigger an event at the
  329. specified threshold, and save data to a temporary file beyond that point.
  330. The initial buffer size will default to 32 bytes which is ByteArrayOutputStream's default buffer size.</div>
  331. <dl>
  332. <dt><span class="paramLabel">Parameters:</span></dt>
  333. <dd><code>threshold</code> - The number of bytes at which to trigger an event.</dd>
  334. <dd><code>prefix</code> - Prefix to use for the temporary file.</dd>
  335. <dd><code>suffix</code> - Suffix to use for the temporary file.</dd>
  336. <dd><code>directory</code> - Temporary file directory.</dd>
  337. <dt><span class="simpleTagLabel">Since:</span></dt>
  338. <dd>1.4</dd>
  339. </dl>
  340. </li>
  341. </ul>
  342. <a name="DeferredFileOutputStream-int-int-java.lang.String-java.lang.String-java.io.File-">
  343. <!-- -->
  344. </a>
  345. <ul class="blockListLast">
  346. <li class="blockList">
  347. <h4>DeferredFileOutputStream</h4>
  348. <pre>public&nbsp;DeferredFileOutputStream(int&nbsp;threshold,
  349. int&nbsp;initialBufferSize,
  350. <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;prefix,
  351. <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;suffix,
  352. <a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;directory)</pre>
  353. <div class="block">Constructs an instance of this class which will trigger an event at the
  354. specified threshold, and save data to a temporary file beyond that point.</div>
  355. <dl>
  356. <dt><span class="paramLabel">Parameters:</span></dt>
  357. <dd><code>threshold</code> - The number of bytes at which to trigger an event.</dd>
  358. <dd><code>initialBufferSize</code> - The initial size of the in memory buffer.</dd>
  359. <dd><code>prefix</code> - Prefix to use for the temporary file.</dd>
  360. <dd><code>suffix</code> - Suffix to use for the temporary file.</dd>
  361. <dd><code>directory</code> - Temporary file directory.</dd>
  362. <dt><span class="simpleTagLabel">Since:</span></dt>
  363. <dd>2.5</dd>
  364. </dl>
  365. </li>
  366. </ul>
  367. </li>
  368. </ul>
  369. <!-- ============ METHOD DETAIL ========== -->
  370. <ul class="blockList">
  371. <li class="blockList"><a name="method.detail">
  372. <!-- -->
  373. </a>
  374. <h3>Method Detail</h3>
  375. <a name="getStream--">
  376. <!-- -->
  377. </a>
  378. <ul class="blockList">
  379. <li class="blockList">
  380. <h4>getStream</h4>
  381. <pre>protected&nbsp;<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;getStream()
  382. 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>
  383. <div class="block">Returns the current output stream. This may be memory based or disk
  384. based, depending on the current state with respect to the threshold.</div>
  385. <dl>
  386. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  387. <dd><code><a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#getStream--">getStream</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html" title="class in org.apache.commons.io.output">ThresholdingOutputStream</a></code></dd>
  388. <dt><span class="returnLabel">Returns:</span></dt>
  389. <dd>The underlying output stream.</dd>
  390. <dt><span class="throwsLabel">Throws:</span></dt>
  391. <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 error occurs.</dd>
  392. </dl>
  393. </li>
  394. </ul>
  395. <a name="thresholdReached--">
  396. <!-- -->
  397. </a>
  398. <ul class="blockList">
  399. <li class="blockList">
  400. <h4>thresholdReached</h4>
  401. <pre>protected&nbsp;void&nbsp;thresholdReached()
  402. 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>
  403. <div class="block">Switches the underlying output stream from a memory based stream to one
  404. that is backed by disk. This is the point at which we realise that too
  405. much data is being written to keep in memory, so we elect to switch to
  406. disk-based storage.</div>
  407. <dl>
  408. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  409. <dd><code><a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#thresholdReached--">thresholdReached</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html" title="class in org.apache.commons.io.output">ThresholdingOutputStream</a></code></dd>
  410. <dt><span class="throwsLabel">Throws:</span></dt>
  411. <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 error occurs.</dd>
  412. </dl>
  413. </li>
  414. </ul>
  415. <a name="isInMemory--">
  416. <!-- -->
  417. </a>
  418. <ul class="blockList">
  419. <li class="blockList">
  420. <h4>isInMemory</h4>
  421. <pre>public&nbsp;boolean&nbsp;isInMemory()</pre>
  422. <div class="block">Determines whether or not the data for this output stream has been
  423. retained in memory.</div>
  424. <dl>
  425. <dt><span class="returnLabel">Returns:</span></dt>
  426. <dd><code>true</code> if the data is available in memory;
  427. <code>false</code> otherwise.</dd>
  428. </dl>
  429. </li>
  430. </ul>
  431. <a name="getData--">
  432. <!-- -->
  433. </a>
  434. <ul class="blockList">
  435. <li class="blockList">
  436. <h4>getData</h4>
  437. <pre>public&nbsp;byte[]&nbsp;getData()</pre>
  438. <div class="block">Returns the data for this output stream as an array of bytes, assuming
  439. that the data has been retained in memory. If the data was written to
  440. disk, this method returns <code>null</code>.</div>
  441. <dl>
  442. <dt><span class="returnLabel">Returns:</span></dt>
  443. <dd>The data for this output stream, or <code>null</code> if no such
  444. data is available.</dd>
  445. </dl>
  446. </li>
  447. </ul>
  448. <a name="getFile--">
  449. <!-- -->
  450. </a>
  451. <ul class="blockList">
  452. <li class="blockList">
  453. <h4>getFile</h4>
  454. <pre>public&nbsp;<a href="http://docs.oracle.com/javase/7/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</a>&nbsp;getFile()</pre>
  455. <div class="block">Returns either the output file specified in the constructor or
  456. the temporary file created or null.
  457. <p>
  458. If the constructor specifying the file is used then it returns that
  459. same output file, even when threshold has not been reached.
  460. <p>
  461. If constructor specifying a temporary file prefix/suffix is used
  462. then the temporary file created once the threshold is reached is returned
  463. If the threshold was not reached then <code>null</code> is returned.</div>
  464. <dl>
  465. <dt><span class="returnLabel">Returns:</span></dt>
  466. <dd>The file for this output stream, or <code>null</code> if no such
  467. file exists.</dd>
  468. </dl>
  469. </li>
  470. </ul>
  471. <a name="close--">
  472. <!-- -->
  473. </a>
  474. <ul class="blockList">
  475. <li class="blockList">
  476. <h4>close</h4>
  477. <pre>public&nbsp;void&nbsp;close()
  478. 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>
  479. <div class="block">Closes underlying output stream, and mark this as closed</div>
  480. <dl>
  481. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  482. <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>
  483. <dt><span class="overrideSpecifyLabel">Specified by:</span></dt>
  484. <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>
  485. <dt><span class="overrideSpecifyLabel">Overrides:</span></dt>
  486. <dd><code><a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html#close--">close</a></code>&nbsp;in class&nbsp;<code><a href="../../../../../org/apache/commons/io/output/ThresholdingOutputStream.html" title="class in org.apache.commons.io.output">ThresholdingOutputStream</a></code></dd>
  487. <dt><span class="throwsLabel">Throws:</span></dt>
  488. <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 error occurs.</dd>
  489. </dl>
  490. </li>
  491. </ul>
  492. <a name="writeTo-java.io.OutputStream-">
  493. <!-- -->
  494. </a>
  495. <ul class="blockListLast">
  496. <li class="blockList">
  497. <h4>writeTo</h4>
  498. <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)
  499. 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>
  500. <div class="block">Writes the data from this output stream to the specified output stream,
  501. after it has been closed.</div>
  502. <dl>
  503. <dt><span class="paramLabel">Parameters:</span></dt>
  504. <dd><code>out</code> - output stream to write to.</dd>
  505. <dt><span class="throwsLabel">Throws:</span></dt>
  506. <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 this stream is not yet closed or an error occurs.</dd>
  507. </dl>
  508. </li>
  509. </ul>
  510. </li>
  511. </ul>
  512. </li>
  513. </ul>
  514. </div>
  515. </div>
  516. <!-- ========= END OF CLASS DATA ========= -->
  517. <!-- ======= START OF BOTTOM NAVBAR ====== -->
  518. <div class="bottomNav"><a name="navbar.bottom">
  519. <!-- -->
  520. </a>
  521. <div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
  522. <a name="navbar.bottom.firstrow">
  523. <!-- -->
  524. </a>
  525. <ul class="navList" title="Navigation">
  526. <li><a href="../../../../../overview-summary.html">Overview</a></li>
  527. <li><a href="package-summary.html">Package</a></li>
  528. <li class="navBarCell1Rev">Class</li>
  529. <li><a href="class-use/DeferredFileOutputStream.html">Use</a></li>
  530. <li><a href="package-tree.html">Tree</a></li>
  531. <li><a href="../../../../../deprecated-list.html">Deprecated</a></li>
  532. <li><a href="../../../../../index-all.html">Index</a></li>
  533. <li><a href="../../../../../help-doc.html">Help</a></li>
  534. </ul>
  535. </div>
  536. <div class="subNav">
  537. <ul class="navList">
  538. <li><a href="../../../../../org/apache/commons/io/output/CountingOutputStream.html" title="class in org.apache.commons.io.output"><span class="typeNameLink">Prev&nbsp;Class</span></a></li>
  539. <li><a href="../../../../../org/apache/commons/io/output/DemuxOutputStream.html" title="class in org.apache.commons.io.output"><span class="typeNameLink">Next&nbsp;Class</span></a></li>
  540. </ul>
  541. <ul class="navList">
  542. <li><a href="../../../../../index.html?org/apache/commons/io/output/DeferredFileOutputStream.html" target="_top">Frames</a></li>
  543. <li><a href="DeferredFileOutputStream.html" target="_top">No&nbsp;Frames</a></li>
  544. </ul>
  545. <ul class="navList" id="allclasses_navbar_bottom">
  546. <li><a href="../../../../../allclasses-noframe.html">All&nbsp;Classes</a></li>
  547. </ul>
  548. <div>
  549. <script type="text/javascript"><!--
  550. allClassesLink = document.getElementById("allclasses_navbar_bottom");
  551. if(window==top) {
  552. allClassesLink.style.display = "block";
  553. }
  554. else {
  555. allClassesLink.style.display = "none";
  556. }
  557. //-->
  558. </script>
  559. </div>
  560. <div>
  561. <ul class="subNavList">
  562. <li>Summary:&nbsp;</li>
  563. <li>Nested&nbsp;|&nbsp;</li>
  564. <li>Field&nbsp;|&nbsp;</li>
  565. <li><a href="#constructor.summary">Constr</a>&nbsp;|&nbsp;</li>
  566. <li><a href="#method.summary">Method</a></li>
  567. </ul>
  568. <ul class="subNavList">
  569. <li>Detail:&nbsp;</li>
  570. <li>Field&nbsp;|&nbsp;</li>
  571. <li><a href="#constructor.detail">Constr</a>&nbsp;|&nbsp;</li>
  572. <li><a href="#method.detail">Method</a></li>
  573. </ul>
  574. </div>
  575. <a name="skip.navbar.bottom">
  576. <!-- -->
  577. </a></div>
  578. <!-- ======== END OF BOTTOM NAVBAR ======= -->
  579. <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>
  580. </body>
  581. </html>