1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<!--NewPage--> 3<HTML> 4<HEAD> 5<!-- Generated by javadoc (build 1.6.0-google-internal) on Mon Jan 04 20:47:59 PST 2010 --> 6<TITLE> 7CountingOutputStream (Guava Libraries 2010.01.04) 8</TITLE> 9 10<META NAME="date" CONTENT="2010-01-04"> 11 12<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style"> 13 14<SCRIPT type="text/javascript"> 15function windowTitle() 16{ 17 if (location.href.indexOf('is-external=true') == -1) { 18 parent.document.title="CountingOutputStream (Guava Libraries 2010.01.04)"; 19 } 20} 21</SCRIPT> 22<NOSCRIPT> 23</NOSCRIPT> 24 25</HEAD> 26 27<BODY BGCOLOR="white" onload="windowTitle();"> 28<HR> 29 30 31<!-- ========= START OF TOP NAVBAR ======= --> 32<A NAME="navbar_top"><!-- --></A> 33<A HREF="#skip-navbar_top" title="Skip navigation links"></A> 34<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 35<TR> 36<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 37<A NAME="navbar_top_firstrow"><!-- --></A> 38<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 39 <TR ALIGN="center" VALIGN="top"> 40 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 41 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 42 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 43 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/CountingOutputStream.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 44 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 45 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 46 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 47 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 48 </TR> 49</TABLE> 50</TD> 51<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 52</EM> 53</TD> 54</TR> 55 56<TR> 57<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 58 <A HREF="../../../../com/google/common/io/CountingInputStream.html" title="class in com.google.common.io"><B>PREV CLASS</B></A> 59 <A HREF="../../../../com/google/common/io/FileBackedOutputStream.html" title="class in com.google.common.io"><B>NEXT CLASS</B></A></FONT></TD> 60<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 61 <A HREF="../../../../index.html?com/google/common/io/CountingOutputStream.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="CountingOutputStream.html" target="_top"><B>NO FRAMES</B></A> 63 <SCRIPT type="text/javascript"> 64 <!-- 65 if(window==top) { 66 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 67 } 68 //--> 69</SCRIPT> 70<NOSCRIPT> 71 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 72</NOSCRIPT> 73 74 75</FONT></TD> 76</TR> 77<TR> 78<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 79 SUMMARY: NESTED | <A HREF="#fields_inherited_from_class_java.io.FilterOutputStream">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> 80<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> 82</TR> 83</TABLE> 84<A NAME="skip-navbar_top"></A> 85<!-- ========= END OF TOP NAVBAR ========= --> 86 87<HR> 88<!-- ======== START OF CLASS DATA ======== --> 89<H2> 90<FONT SIZE="-1"> 91com.google.common.io</FONT> 92<BR> 93Class CountingOutputStream</H2> 94<PRE> 95<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">java.lang.Object</A> 96 <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">java.io.OutputStream</A> 97 <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true" title="class or interface in java.io">java.io.FilterOutputStream</A> 98 <IMG SRC="../../../../resources/inherit.gif" ALT="extended by "><B>com.google.common.io.CountingOutputStream</B> 99</PRE> 100<DL> 101<DT><B>All Implemented Interfaces:</B> <DD><A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io">Closeable</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/io/Flushable.html?is-external=true" title="class or interface in java.io">Flushable</A></DD> 102</DL> 103<HR> 104<DL> 105<DT><PRE>public class <B>CountingOutputStream</B><DT>extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true" title="class or interface in java.io">FilterOutputStream</A></DL> 106</PRE> 107 108<P> 109An OutputStream that counts the number of bytes written. 110<P> 111 112<P> 113<DL> 114<DT><B>Since:</B></DT> 115 <DD>2009.09.15 <b>tentative</b></DD> 116<DT><B>Author:</B></DT> 117 <DD>Chris Nokleberg</DD> 118</DL> 119<HR> 120 121<P> 122<!-- =========== FIELD SUMMARY =========== --> 123 124<A NAME="field_summary"><!-- --></A> 125<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 126<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 127<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 128<B>Field Summary</B></FONT></TH> 129</TR> 130</TABLE> 131 <A NAME="fields_inherited_from_class_java.io.FilterOutputStream"><!-- --></A> 132<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 133<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 134<TH ALIGN="left"><B>Fields inherited from class java.io.<A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true" title="class or interface in java.io">FilterOutputStream</A></B></TH> 135</TR> 136<TR BGCOLOR="white" CLASS="TableRowColor"> 137<TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true#out" title="class or interface in java.io">out</A></CODE></TD> 138</TR> 139</TABLE> 140 141<!-- ======== CONSTRUCTOR SUMMARY ======== --> 142 143<A NAME="constructor_summary"><!-- --></A> 144<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 145<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 146<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 147<B>Constructor Summary</B></FONT></TH> 148</TR> 149<TR BGCOLOR="white" CLASS="TableRowColor"> 150<TD><CODE><B><A HREF="../../../../com/google/common/io/CountingOutputStream.html#CountingOutputStream(java.io.OutputStream)">CountingOutputStream</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</A> out)</CODE> 151 152<BR> 153 Wraps another output stream, counting the number of bytes written.</TD> 154</TR> 155</TABLE> 156 157<!-- ========== METHOD SUMMARY =========== --> 158 159<A NAME="method_summary"><!-- --></A> 160<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 161<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 162<TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 163<B>Method Summary</B></FONT></TH> 164</TR> 165<TR BGCOLOR="white" CLASS="TableRowColor"> 166<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 167<CODE> long</CODE></FONT></TD> 168<TD><CODE><B><A HREF="../../../../com/google/common/io/CountingOutputStream.html#getCount()">getCount</A></B>()</CODE> 169 170<BR> 171 Returns the number of bytes written.</TD> 172</TR> 173<TR BGCOLOR="white" CLASS="TableRowColor"> 174<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 175<CODE> void</CODE></FONT></TD> 176<TD><CODE><B><A HREF="../../../../com/google/common/io/CountingOutputStream.html#write(byte[], int, int)">write</A></B>(byte[] b, 177 int off, 178 int len)</CODE> 179 180<BR> 181 </TD> 182</TR> 183<TR BGCOLOR="white" CLASS="TableRowColor"> 184<TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 185<CODE> void</CODE></FONT></TD> 186<TD><CODE><B><A HREF="../../../../com/google/common/io/CountingOutputStream.html#write(int)">write</A></B>(int b)</CODE> 187 188<BR> 189 </TD> 190</TR> 191</TABLE> 192 <A NAME="methods_inherited_from_class_java.io.FilterOutputStream"><!-- --></A> 193<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 194<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 195<TH ALIGN="left"><B>Methods inherited from class java.io.<A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true" title="class or interface in java.io">FilterOutputStream</A></B></TH> 196</TR> 197<TR BGCOLOR="white" CLASS="TableRowColor"> 198<TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true#close()" title="class or interface in java.io">close</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true#flush()" title="class or interface in java.io">flush</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true#write(byte[])" title="class or interface in java.io">write</A></CODE></TD> 199</TR> 200</TABLE> 201 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> 202<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 203<TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 204<TH ALIGN="left"><B>Methods inherited from class java.lang.<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true" title="class or interface in java.lang">Object</A></B></TH> 205</TR> 206<TR BGCOLOR="white" CLASS="TableRowColor"> 207<TD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#clone()" title="class or interface in java.lang">clone</A>, <A HREF="http://java.sun.com/javase/6/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://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#finalize()" title="class or interface in java.lang">finalize</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#getClass()" title="class or interface in java.lang">getClass</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#hashCode()" title="class or interface in java.lang">hashCode</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notify()" title="class or interface in java.lang">notify</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#notifyAll()" title="class or interface in java.lang">notifyAll</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#toString()" title="class or interface in java.lang">toString</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait()" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long)" title="class or interface in java.lang">wait</A>, <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Object.html?is-external=true#wait(long, int)" title="class or interface in java.lang">wait</A></CODE></TD> 208</TR> 209</TABLE> 210 211<P> 212 213<!-- ========= CONSTRUCTOR DETAIL ======== --> 214 215<A NAME="constructor_detail"><!-- --></A> 216<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 217<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 218<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 219<B>Constructor Detail</B></FONT></TH> 220</TR> 221</TABLE> 222 223<A NAME="CountingOutputStream(java.io.OutputStream)"><!-- --></A><H3> 224CountingOutputStream</H3> 225<PRE> 226public <B>CountingOutputStream</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io">OutputStream</A> out)</PRE> 227<DL> 228<DD>Wraps another output stream, counting the number of bytes written. 229<P> 230<DL> 231<DT><B>Parameters:</B><DD><CODE>out</CODE> - the output stream to be wrapped</DL> 232</DL> 233 234<!-- ============ METHOD DETAIL ========== --> 235 236<A NAME="method_detail"><!-- --></A> 237<TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 238<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 239<TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 240<B>Method Detail</B></FONT></TH> 241</TR> 242</TABLE> 243 244<A NAME="getCount()"><!-- --></A><H3> 245getCount</H3> 246<PRE> 247public long <B>getCount</B>()</PRE> 248<DL> 249<DD>Returns the number of bytes written. 250<P> 251<DD><DL> 252</DL> 253</DD> 254</DL> 255<HR> 256 257<A NAME="write(byte[], int, int)"><!-- --></A><H3> 258write</H3> 259<PRE> 260public void <B>write</B>(byte[] b, 261 int off, 262 int len) 263 throws <A HREF="http://java.sun.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE> 264<DL> 265<DD><DL> 266<DT><B>Overrides:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true#write(byte[], int, int)" title="class or interface in java.io">write</A></CODE> in class <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true" title="class or interface in java.io">FilterOutputStream</A></CODE></DL> 267</DD> 268<DD><DL> 269 270<DT><B>Throws:</B> 271<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL> 272</DD> 273</DL> 274<HR> 275 276<A NAME="write(int)"><!-- --></A><H3> 277write</H3> 278<PRE> 279public void <B>write</B>(int b) 280 throws <A HREF="http://java.sun.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></PRE> 281<DL> 282<DD><DL> 283<DT><B>Overrides:</B><DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true#write(int)" title="class or interface in java.io">write</A></CODE> in class <CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FilterOutputStream.html?is-external=true" title="class or interface in java.io">FilterOutputStream</A></CODE></DL> 284</DD> 285<DD><DL> 286 287<DT><B>Throws:</B> 288<DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/IOException.html?is-external=true" title="class or interface in java.io">IOException</A></CODE></DL> 289</DD> 290</DL> 291<!-- ========= END OF CLASS DATA ========= --> 292<HR> 293 294 295<!-- ======= START OF BOTTOM NAVBAR ====== --> 296<A NAME="navbar_bottom"><!-- --></A> 297<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 298<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 299<TR> 300<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 301<A NAME="navbar_bottom_firstrow"><!-- --></A> 302<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 303 <TR ALIGN="center" VALIGN="top"> 304 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 305 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 306 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 307 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/CountingOutputStream.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 308 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 309 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 310 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 311 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 312 </TR> 313</TABLE> 314</TD> 315<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 316</EM> 317</TD> 318</TR> 319 320<TR> 321<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 322 <A HREF="../../../../com/google/common/io/CountingInputStream.html" title="class in com.google.common.io"><B>PREV CLASS</B></A> 323 <A HREF="../../../../com/google/common/io/FileBackedOutputStream.html" title="class in com.google.common.io"><B>NEXT CLASS</B></A></FONT></TD> 324<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 325 <A HREF="../../../../index.html?com/google/common/io/CountingOutputStream.html" target="_top"><B>FRAMES</B></A> 326 <A HREF="CountingOutputStream.html" target="_top"><B>NO FRAMES</B></A> 327 <SCRIPT type="text/javascript"> 328 <!-- 329 if(window==top) { 330 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 331 } 332 //--> 333</SCRIPT> 334<NOSCRIPT> 335 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 336</NOSCRIPT> 337 338 339</FONT></TD> 340</TR> 341<TR> 342<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 343 SUMMARY: NESTED | <A HREF="#fields_inherited_from_class_java.io.FilterOutputStream">FIELD</A> | <A HREF="#constructor_summary">CONSTR</A> | <A HREF="#method_summary">METHOD</A></FONT></TD> 344<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 345DETAIL: FIELD | <A HREF="#constructor_detail">CONSTR</A> | <A HREF="#method_detail">METHOD</A></FONT></TD> 346</TR> 347</TABLE> 348<A NAME="skip-navbar_bottom"></A> 349<!-- ======== END OF BOTTOM NAVBAR ======= --> 350 351<HR> 352 353</BODY> 354</HTML> 355