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> 7 ByteStreams (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"> 15 function windowTitle() 16 { 17 if (location.href.indexOf('is-external=true') == -1) { 18 parent.document.title="ByteStreams (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/ByteStreams.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/ByteProcessor.html" title="interface in com.google.common.io"><B>PREV CLASS</B></A> 59 <A HREF="../../../../com/google/common/io/CharStreams.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/ByteStreams.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="ByteStreams.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 | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 80 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 81 DETAIL: FIELD | CONSTR | <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"> 91 com.google.common.io</FONT> 92 <BR> 93 Class ByteStreams</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 "><B>com.google.common.io.ByteStreams</B> 97 </PRE> 98 <HR> 99 <DL> 100 <DT><PRE>public final class <B>ByteStreams</B><DT>extends <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></DL> 101 </PRE> 102 103 <P> 104 Provides utility methods for working with byte arrays and I/O streams. 105 106 <p>All method parameters must be non-null unless documented otherwise. 107 <P> 108 109 <P> 110 <DL> 111 <DT><B>Since:</B></DT> 112 <DD>2009.09.15 <b>tentative</b></DD> 113 <DT><B>Author:</B></DT> 114 <DD>Chris Nokleberg</DD> 115 </DL> 116 <HR> 117 118 <P> 119 120 <!-- ========== METHOD SUMMARY =========== --> 121 122 <A NAME="method_summary"><!-- --></A> 123 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 124 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 125 <TH ALIGN="left" COLSPAN="2"><FONT SIZE="+2"> 126 <B>Method Summary</B></FONT></TH> 127 </TR> 128 <TR BGCOLOR="white" CLASS="TableRowColor"> 129 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 130 <CODE>static long</CODE></FONT></TD> 131 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#copy(java.io.InputStream, java.io.OutputStream)">copy</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> from, 132 <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> to)</CODE> 133 134 <BR> 135 Copies all bytes from the input stream to the output stream.</TD> 136 </TR> 137 <TR BGCOLOR="white" CLASS="TableRowColor"> 138 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 139 <CODE>static long</CODE></FONT></TD> 140 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#copy(com.google.common.io.InputSupplier, java.io.OutputStream)">copy</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> from, 141 <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> to)</CODE> 142 143 <BR> 144 Opens an input stream from the supplier, copies all bytes from the 145 input to the output, and closes the input stream.</TD> 146 </TR> 147 <TR BGCOLOR="white" CLASS="TableRowColor"> 148 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 149 <CODE>static long</CODE></FONT></TD> 150 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#copy(com.google.common.io.InputSupplier, com.google.common.io.OutputSupplier)">copy</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> from, 151 <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><? extends <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>> to)</CODE> 152 153 <BR> 154 Opens input and output streams from the given suppliers, copies all 155 bytes from the input to the output, and closes the streams.</TD> 156 </TR> 157 <TR BGCOLOR="white" CLASS="TableRowColor"> 158 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 159 <CODE>static long</CODE></FONT></TD> 160 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#copy(java.nio.channels.ReadableByteChannel, java.nio.channels.WritableByteChannel)">copy</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/ReadableByteChannel.html?is-external=true" title="class or interface in java.nio.channels">ReadableByteChannel</A> from, 161 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/WritableByteChannel.html?is-external=true" title="class or interface in java.nio.channels">WritableByteChannel</A> to)</CODE> 162 163 <BR> 164 Copies all bytes from the readable channel to the writable channel.</TD> 165 </TR> 166 <TR BGCOLOR="white" CLASS="TableRowColor"> 167 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 168 <CODE>static boolean</CODE></FONT></TD> 169 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#equal(com.google.common.io.InputSupplier, com.google.common.io.InputSupplier)">equal</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier1, 170 <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier2)</CODE> 171 172 <BR> 173 Returns true if the supplied input streams contain the same bytes.</TD> 174 </TR> 175 <TR BGCOLOR="white" CLASS="TableRowColor"> 176 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 177 <CODE>static long</CODE></FONT></TD> 178 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#getChecksum(com.google.common.io.InputSupplier, java.util.zip.Checksum)">getChecksum</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier, 179 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/zip/Checksum.html?is-external=true" title="class or interface in java.util.zip">Checksum</A> checksum)</CODE> 180 181 <BR> 182 Computes and returns the checksum value for a supplied input stream.</TD> 183 </TR> 184 <TR BGCOLOR="white" CLASS="TableRowColor"> 185 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 186 <CODE>static byte[]</CODE></FONT></TD> 187 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#getDigest(com.google.common.io.InputSupplier, java.security.MessageDigest)">getDigest</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier, 188 <A HREF="http://java.sun.com/javase/6/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security">MessageDigest</A> md)</CODE> 189 190 <BR> 191 Computes and returns the digest value for a supplied input stream.</TD> 192 </TR> 193 <TR BGCOLOR="white" CLASS="TableRowColor"> 194 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 195 <CODE>static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>></CODE></FONT></TD> 196 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#join(com.google.common.io.InputSupplier...)">join</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>>... suppliers)</CODE> 197 198 <BR> 199 Varargs form of <A HREF="../../../../com/google/common/io/ByteStreams.html#join(java.lang.Iterable)"><CODE>join(Iterable)</CODE></A>.</TD> 200 </TR> 201 <TR BGCOLOR="white" CLASS="TableRowColor"> 202 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 203 <CODE>static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>></CODE></FONT></TD> 204 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#join(java.lang.Iterable)">join</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A><? extends <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>>> suppliers)</CODE> 205 206 <BR> 207 Joins multiple <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io"><CODE>InputStream</CODE></A> suppliers into a single supplier.</TD> 208 </TR> 209 <TR BGCOLOR="white" CLASS="TableRowColor"> 210 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 211 <CODE>static long</CODE></FONT></TD> 212 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#length(com.google.common.io.InputSupplier)">length</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier)</CODE> 213 214 <BR> 215 Returns the length of a supplied input stream, in bytes.</TD> 216 </TR> 217 <TR BGCOLOR="white" CLASS="TableRowColor"> 218 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 219 <CODE>static <A HREF="../../../../com/google/common/io/ByteArrayDataInput.html" title="interface in com.google.common.io">ByteArrayDataInput</A></CODE></FONT></TD> 220 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#newDataInput(byte[])">newDataInput</A></B>(byte[] bytes)</CODE> 221 222 <BR> 223 Returns a new <A HREF="../../../../com/google/common/io/ByteArrayDataInput.html" title="interface in com.google.common.io"><CODE>ByteArrayDataInput</CODE></A> instance to read from the <code>bytes</code> array from the beginning.</TD> 224 </TR> 225 <TR BGCOLOR="white" CLASS="TableRowColor"> 226 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 227 <CODE>static <A HREF="../../../../com/google/common/io/ByteArrayDataInput.html" title="interface in com.google.common.io">ByteArrayDataInput</A></CODE></FONT></TD> 228 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#newDataInput(byte[], int)">newDataInput</A></B>(byte[] bytes, 229 int start)</CODE> 230 231 <BR> 232 Returns a new <A HREF="../../../../com/google/common/io/ByteArrayDataInput.html" title="interface in com.google.common.io"><CODE>ByteArrayDataInput</CODE></A> instance to read from the <code>bytes</code> array, starting at the given position.</TD> 233 </TR> 234 <TR BGCOLOR="white" CLASS="TableRowColor"> 235 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 236 <CODE>static <A HREF="../../../../com/google/common/io/ByteArrayDataOutput.html" title="interface in com.google.common.io">ByteArrayDataOutput</A></CODE></FONT></TD> 237 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#newDataOutput()">newDataOutput</A></B>()</CODE> 238 239 <BR> 240 Returns a new <A HREF="../../../../com/google/common/io/ByteArrayDataOutput.html" title="interface in com.google.common.io"><CODE>ByteArrayDataOutput</CODE></A> instance with a default size.</TD> 241 </TR> 242 <TR BGCOLOR="white" CLASS="TableRowColor"> 243 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 244 <CODE>static <A HREF="../../../../com/google/common/io/ByteArrayDataOutput.html" title="interface in com.google.common.io">ByteArrayDataOutput</A></CODE></FONT></TD> 245 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#newDataOutput(int)">newDataOutput</A></B>(int size)</CODE> 246 247 <BR> 248 Returns a new <A HREF="../../../../com/google/common/io/ByteArrayDataOutput.html" title="interface in com.google.common.io"><CODE>ByteArrayDataOutput</CODE></A> instance sized to hold 249 <code>size</code> bytes before resizing.</TD> 250 </TR> 251 <TR BGCOLOR="white" CLASS="TableRowColor"> 252 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 253 <CODE>static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html?is-external=true" title="class or interface in java.io">ByteArrayInputStream</A>></CODE></FONT></TD> 254 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#newInputStreamSupplier(byte[])">newInputStreamSupplier</A></B>(byte[] b)</CODE> 255 256 <BR> 257 Returns a factory that will supply instances of 258 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html?is-external=true" title="class or interface in java.io"><CODE>ByteArrayInputStream</CODE></A> that read from the given byte array.</TD> 259 </TR> 260 <TR BGCOLOR="white" CLASS="TableRowColor"> 261 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 262 <CODE>static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html?is-external=true" title="class or interface in java.io">ByteArrayInputStream</A>></CODE></FONT></TD> 263 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#newInputStreamSupplier(byte[], int, int)">newInputStreamSupplier</A></B>(byte[] b, 264 int off, 265 int len)</CODE> 266 267 <BR> 268 Returns a factory that will supply instances of 269 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html?is-external=true" title="class or interface in java.io"><CODE>ByteArrayInputStream</CODE></A> that read from the given byte array.</TD> 270 </TR> 271 <TR BGCOLOR="white" CLASS="TableRowColor"> 272 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 273 <CODE>static int</CODE></FONT></TD> 274 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#read(java.io.InputStream, byte[], int, int)">read</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in, 275 byte[] b, 276 int off, 277 int len)</CODE> 278 279 <BR> 280 Reads some bytes from an input stream and stores them into the buffer array 281 <code>b</code>.</TD> 282 </TR> 283 <TR BGCOLOR="white" CLASS="TableRowColor"> 284 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 285 <CODE>static 286 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 287 <TR ALIGN="right" VALIGN=""> 288 <TD NOWRAP><FONT SIZE="-1"> 289 <CODE><T> T</CODE></FONT></TD> 290 </TR> 291 </TABLE> 292 </CODE></FONT></TD> 293 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#readBytes(com.google.common.io.InputSupplier, com.google.common.io.ByteProcessor)">readBytes</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier, 294 <A HREF="../../../../com/google/common/io/ByteProcessor.html" title="interface in com.google.common.io">ByteProcessor</A><T> processor)</CODE> 295 296 <BR> 297 Process the bytes of a supplied stream</TD> 298 </TR> 299 <TR BGCOLOR="white" CLASS="TableRowColor"> 300 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 301 <CODE>static void</CODE></FONT></TD> 302 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#readFully(java.io.InputStream, byte[])">readFully</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in, 303 byte[] b)</CODE> 304 305 <BR> 306 Attempts to read enough bytes from the stream to fill the given byte array, 307 with the same behavior as <A HREF="http://java.sun.com/javase/6/docs/api/java/io/DataInput.html?is-external=true#readFully(byte[])" title="class or interface in java.io"><CODE>DataInput.readFully(byte[])</CODE></A>.</TD> 308 </TR> 309 <TR BGCOLOR="white" CLASS="TableRowColor"> 310 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 311 <CODE>static void</CODE></FONT></TD> 312 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#readFully(java.io.InputStream, byte[], int, int)">readFully</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in, 313 byte[] b, 314 int off, 315 int len)</CODE> 316 317 <BR> 318 Attempts to read <code>len</code> bytes from the stream into the given array 319 starting at <code>off</code>, with the same behavior as 320 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/DataInput.html?is-external=true#readFully(byte[], int, int)" title="class or interface in java.io"><CODE>DataInput.readFully(byte[], int, int)</CODE></A>.</TD> 321 </TR> 322 <TR BGCOLOR="white" CLASS="TableRowColor"> 323 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 324 <CODE>static void</CODE></FONT></TD> 325 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#skipFully(java.io.InputStream, long)">skipFully</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in, 326 long n)</CODE> 327 328 <BR> 329 Discards <code>n</code> bytes of data from the input stream.</TD> 330 </TR> 331 <TR BGCOLOR="white" CLASS="TableRowColor"> 332 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 333 <CODE>static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>></CODE></FONT></TD> 334 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#slice(com.google.common.io.InputSupplier, long, long)">slice</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier, 335 long offset, 336 long length)</CODE> 337 338 <BR> 339 Returns an <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io"><CODE>InputSupplier</CODE></A> that returns input streams from the 340 an underlying supplier, where each stream starts at the given 341 offset and is limited to the specified number of bytes.</TD> 342 </TR> 343 <TR BGCOLOR="white" CLASS="TableRowColor"> 344 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 345 <CODE>static byte[]</CODE></FONT></TD> 346 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#toByteArray(java.io.InputStream)">toByteArray</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in)</CODE> 347 348 <BR> 349 Reads all bytes from an input stream into a byte array.</TD> 350 </TR> 351 <TR BGCOLOR="white" CLASS="TableRowColor"> 352 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 353 <CODE>static byte[]</CODE></FONT></TD> 354 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#toByteArray(com.google.common.io.InputSupplier)">toByteArray</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier)</CODE> 355 356 <BR> 357 Returns the data from a <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io"><CODE>InputStream</CODE></A> factory as a byte array.</TD> 358 </TR> 359 <TR BGCOLOR="white" CLASS="TableRowColor"> 360 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 361 <CODE>static void</CODE></FONT></TD> 362 <TD><CODE><B><A HREF="../../../../com/google/common/io/ByteStreams.html#write(byte[], com.google.common.io.OutputSupplier)">write</A></B>(byte[] from, 363 <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><? extends <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>> to)</CODE> 364 365 <BR> 366 Writes a byte array to an output stream from the given supplier.</TD> 367 </TR> 368 </TABLE> 369 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> 370 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 371 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 372 <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> 373 </TR> 374 <TR BGCOLOR="white" CLASS="TableRowColor"> 375 <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> 376 </TR> 377 </TABLE> 378 379 <P> 380 381 <!-- ============ METHOD DETAIL ========== --> 382 383 <A NAME="method_detail"><!-- --></A> 384 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 385 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 386 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 387 <B>Method Detail</B></FONT></TH> 388 </TR> 389 </TABLE> 390 391 <A NAME="newInputStreamSupplier(byte[])"><!-- --></A><H3> 392 newInputStreamSupplier</H3> 393 <PRE> 394 public static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html?is-external=true" title="class or interface in java.io">ByteArrayInputStream</A>> <B>newInputStreamSupplier</B>(byte[] b)</PRE> 395 <DL> 396 <DD>Returns a factory that will supply instances of 397 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html?is-external=true" title="class or interface in java.io"><CODE>ByteArrayInputStream</CODE></A> that read from the given byte array. 398 <P> 399 <DD><DL> 400 <DT><B>Parameters:</B><DD><CODE>b</CODE> - the input buffer 401 <DT><B>Returns:</B><DD>the factory</DL> 402 </DD> 403 </DL> 404 <HR> 405 406 <A NAME="newInputStreamSupplier(byte[], int, int)"><!-- --></A><H3> 407 newInputStreamSupplier</H3> 408 <PRE> 409 public static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html?is-external=true" title="class or interface in java.io">ByteArrayInputStream</A>> <B>newInputStreamSupplier</B>(byte[] b, 410 int off, 411 int len)</PRE> 412 <DL> 413 <DD>Returns a factory that will supply instances of 414 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/ByteArrayInputStream.html?is-external=true" title="class or interface in java.io"><CODE>ByteArrayInputStream</CODE></A> that read from the given byte array. 415 <P> 416 <DD><DL> 417 <DT><B>Parameters:</B><DD><CODE>b</CODE> - the input buffer<DD><CODE>off</CODE> - the offset in the buffer of the first byte to read<DD><CODE>len</CODE> - the maximum number of bytes to read from the buffer 418 <DT><B>Returns:</B><DD>the factory</DL> 419 </DD> 420 </DL> 421 <HR> 422 423 <A NAME="write(byte[], com.google.common.io.OutputSupplier)"><!-- --></A><H3> 424 write</H3> 425 <PRE> 426 public static void <B>write</B>(byte[] from, 427 <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><? extends <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>> to) 428 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> 429 <DL> 430 <DD>Writes a byte array to an output stream from the given supplier. 431 <P> 432 <DD><DL> 433 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the bytes to write<DD><CODE>to</CODE> - the output supplier 434 <DT><B>Throws:</B> 435 <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> - if an I/O error occurs</DL> 436 </DD> 437 </DL> 438 <HR> 439 440 <A NAME="copy(com.google.common.io.InputSupplier, com.google.common.io.OutputSupplier)"><!-- --></A><H3> 441 copy</H3> 442 <PRE> 443 public static long <B>copy</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> from, 444 <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><? extends <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>> to) 445 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> 446 <DL> 447 <DD>Opens input and output streams from the given suppliers, copies all 448 bytes from the input to the output, and closes the streams. 449 <P> 450 <DD><DL> 451 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the input factory<DD><CODE>to</CODE> - the output factory 452 <DT><B>Returns:</B><DD>the number of bytes copied 453 <DT><B>Throws:</B> 454 <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> - if an I/O error occurs</DL> 455 </DD> 456 </DL> 457 <HR> 458 459 <A NAME="copy(com.google.common.io.InputSupplier, java.io.OutputStream)"><!-- --></A><H3> 460 copy</H3> 461 <PRE> 462 public static long <B>copy</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> from, 463 <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> to) 464 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> 465 <DL> 466 <DD>Opens an input stream from the supplier, copies all bytes from the 467 input to the output, and closes the input stream. Does not close 468 or flush the output stream. 469 <P> 470 <DD><DL> 471 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the input factory<DD><CODE>to</CODE> - the output stream to write to 472 <DT><B>Returns:</B><DD>the number of bytes copied 473 <DT><B>Throws:</B> 474 <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> - if an I/O error occurs</DL> 475 </DD> 476 </DL> 477 <HR> 478 479 <A NAME="copy(java.io.InputStream, java.io.OutputStream)"><!-- --></A><H3> 480 copy</H3> 481 <PRE> 482 public static long <B>copy</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> from, 483 <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> to) 484 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> 485 <DL> 486 <DD>Copies all bytes from the input stream to the output stream. 487 Does not close or flush either stream. 488 <P> 489 <DD><DL> 490 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the input stream to read from<DD><CODE>to</CODE> - the output stream to write to 491 <DT><B>Returns:</B><DD>the number of bytes copied 492 <DT><B>Throws:</B> 493 <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> - if an I/O error occurs</DL> 494 </DD> 495 </DL> 496 <HR> 497 498 <A NAME="copy(java.nio.channels.ReadableByteChannel, java.nio.channels.WritableByteChannel)"><!-- --></A><H3> 499 copy</H3> 500 <PRE> 501 public static long <B>copy</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/ReadableByteChannel.html?is-external=true" title="class or interface in java.nio.channels">ReadableByteChannel</A> from, 502 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/WritableByteChannel.html?is-external=true" title="class or interface in java.nio.channels">WritableByteChannel</A> to) 503 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> 504 <DL> 505 <DD>Copies all bytes from the readable channel to the writable channel. 506 Does not close or flush either channel. 507 <P> 508 <DD><DL> 509 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the readable channel to read from<DD><CODE>to</CODE> - the writable channel to write to 510 <DT><B>Returns:</B><DD>the number of bytes copied 511 <DT><B>Throws:</B> 512 <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> - if an I/O error occurs</DL> 513 </DD> 514 </DL> 515 <HR> 516 517 <A NAME="toByteArray(java.io.InputStream)"><!-- --></A><H3> 518 toByteArray</H3> 519 <PRE> 520 public static byte[] <B>toByteArray</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in) 521 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> 522 <DL> 523 <DD>Reads all bytes from an input stream into a byte array. 524 Does not close the stream. 525 <P> 526 <DD><DL> 527 <DT><B>Parameters:</B><DD><CODE>in</CODE> - the input stream to read from 528 <DT><B>Returns:</B><DD>a byte array containing all the bytes from the stream 529 <DT><B>Throws:</B> 530 <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> - if an I/O error occurs</DL> 531 </DD> 532 </DL> 533 <HR> 534 535 <A NAME="toByteArray(com.google.common.io.InputSupplier)"><!-- --></A><H3> 536 toByteArray</H3> 537 <PRE> 538 public static byte[] <B>toByteArray</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier) 539 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> 540 <DL> 541 <DD>Returns the data from a <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io"><CODE>InputStream</CODE></A> factory as a byte array. 542 <P> 543 <DD><DL> 544 <DT><B>Parameters:</B><DD><CODE>supplier</CODE> - the factory 545 <DT><B>Throws:</B> 546 <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> - if an I/O error occurs</DL> 547 </DD> 548 </DL> 549 <HR> 550 551 <A NAME="newDataInput(byte[])"><!-- --></A><H3> 552 newDataInput</H3> 553 <PRE> 554 public static <A HREF="../../../../com/google/common/io/ByteArrayDataInput.html" title="interface in com.google.common.io">ByteArrayDataInput</A> <B>newDataInput</B>(byte[] bytes)</PRE> 555 <DL> 556 <DD>Returns a new <A HREF="../../../../com/google/common/io/ByteArrayDataInput.html" title="interface in com.google.common.io"><CODE>ByteArrayDataInput</CODE></A> instance to read from the <code>bytes</code> array from the beginning. 557 <P> 558 <DD><DL> 559 </DL> 560 </DD> 561 </DL> 562 <HR> 563 564 <A NAME="newDataInput(byte[], int)"><!-- --></A><H3> 565 newDataInput</H3> 566 <PRE> 567 public static <A HREF="../../../../com/google/common/io/ByteArrayDataInput.html" title="interface in com.google.common.io">ByteArrayDataInput</A> <B>newDataInput</B>(byte[] bytes, 568 int start)</PRE> 569 <DL> 570 <DD>Returns a new <A HREF="../../../../com/google/common/io/ByteArrayDataInput.html" title="interface in com.google.common.io"><CODE>ByteArrayDataInput</CODE></A> instance to read from the <code>bytes</code> array, starting at the given position. 571 <P> 572 <DD><DL> 573 574 <DT><B>Throws:</B> 575 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IndexOutOfBoundsException.html?is-external=true" title="class or interface in java.lang">IndexOutOfBoundsException</A></CODE> - if <code>start</code> is negative or greater 576 than the length of the array</DL> 577 </DD> 578 </DL> 579 <HR> 580 581 <A NAME="newDataOutput()"><!-- --></A><H3> 582 newDataOutput</H3> 583 <PRE> 584 public static <A HREF="../../../../com/google/common/io/ByteArrayDataOutput.html" title="interface in com.google.common.io">ByteArrayDataOutput</A> <B>newDataOutput</B>()</PRE> 585 <DL> 586 <DD>Returns a new <A HREF="../../../../com/google/common/io/ByteArrayDataOutput.html" title="interface in com.google.common.io"><CODE>ByteArrayDataOutput</CODE></A> instance with a default size. 587 <P> 588 <DD><DL> 589 </DL> 590 </DD> 591 </DL> 592 <HR> 593 594 <A NAME="newDataOutput(int)"><!-- --></A><H3> 595 newDataOutput</H3> 596 <PRE> 597 public static <A HREF="../../../../com/google/common/io/ByteArrayDataOutput.html" title="interface in com.google.common.io">ByteArrayDataOutput</A> <B>newDataOutput</B>(int size)</PRE> 598 <DL> 599 <DD>Returns a new <A HREF="../../../../com/google/common/io/ByteArrayDataOutput.html" title="interface in com.google.common.io"><CODE>ByteArrayDataOutput</CODE></A> instance sized to hold 600 <code>size</code> bytes before resizing. 601 <P> 602 <DD><DL> 603 604 <DT><B>Throws:</B> 605 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if <code>size</code> is negative</DL> 606 </DD> 607 </DL> 608 <HR> 609 610 <A NAME="length(com.google.common.io.InputSupplier)"><!-- --></A><H3> 611 length</H3> 612 <PRE> 613 public static long <B>length</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier) 614 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> 615 <DL> 616 <DD>Returns the length of a supplied input stream, in bytes. 617 <P> 618 <DD><DL> 619 620 <DT><B>Throws:</B> 621 <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> 622 </DD> 623 </DL> 624 <HR> 625 626 <A NAME="equal(com.google.common.io.InputSupplier, com.google.common.io.InputSupplier)"><!-- --></A><H3> 627 equal</H3> 628 <PRE> 629 public static boolean <B>equal</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier1, 630 <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier2) 631 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> 632 <DL> 633 <DD>Returns true if the supplied input streams contain the same bytes. 634 <P> 635 <DD><DL> 636 637 <DT><B>Throws:</B> 638 <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> - if an I/O error occurs</DL> 639 </DD> 640 </DL> 641 <HR> 642 643 <A NAME="readFully(java.io.InputStream, byte[])"><!-- --></A><H3> 644 readFully</H3> 645 <PRE> 646 public static void <B>readFully</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in, 647 byte[] b) 648 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> 649 <DL> 650 <DD>Attempts to read enough bytes from the stream to fill the given byte array, 651 with the same behavior as <A HREF="http://java.sun.com/javase/6/docs/api/java/io/DataInput.html?is-external=true#readFully(byte[])" title="class or interface in java.io"><CODE>DataInput.readFully(byte[])</CODE></A>. 652 Does not close the stream. 653 <P> 654 <DD><DL> 655 <DT><B>Parameters:</B><DD><CODE>in</CODE> - the input stream to read from.<DD><CODE>b</CODE> - the buffer into which the data is read. 656 <DT><B>Throws:</B> 657 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/EOFException.html?is-external=true" title="class or interface in java.io">EOFException</A></CODE> - if this stream reaches the end before reading all 658 the bytes. 659 <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> - if an I/O error occurs.</DL> 660 </DD> 661 </DL> 662 <HR> 663 664 <A NAME="readFully(java.io.InputStream, byte[], int, int)"><!-- --></A><H3> 665 readFully</H3> 666 <PRE> 667 public static void <B>readFully</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in, 668 byte[] b, 669 int off, 670 int len) 671 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> 672 <DL> 673 <DD>Attempts to read <code>len</code> bytes from the stream into the given array 674 starting at <code>off</code>, with the same behavior as 675 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/DataInput.html?is-external=true#readFully(byte[], int, int)" title="class or interface in java.io"><CODE>DataInput.readFully(byte[], int, int)</CODE></A>. Does not close the 676 stream. 677 <P> 678 <DD><DL> 679 <DT><B>Parameters:</B><DD><CODE>in</CODE> - the input stream to read from.<DD><CODE>b</CODE> - the buffer into which the data is read.<DD><CODE>off</CODE> - an int specifying the offset into the data.<DD><CODE>len</CODE> - an int specifying the number of bytes to read. 680 <DT><B>Throws:</B> 681 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/EOFException.html?is-external=true" title="class or interface in java.io">EOFException</A></CODE> - if this stream reaches the end before reading all 682 the bytes. 683 <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> - if an I/O error occurs.</DL> 684 </DD> 685 </DL> 686 <HR> 687 688 <A NAME="skipFully(java.io.InputStream, long)"><!-- --></A><H3> 689 skipFully</H3> 690 <PRE> 691 public static void <B>skipFully</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in, 692 long n) 693 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> 694 <DL> 695 <DD>Discards <code>n</code> bytes of data from the input stream. This method 696 will block until the full amount has been skipped. Does not close the 697 stream. 698 <P> 699 <DD><DL> 700 <DT><B>Parameters:</B><DD><CODE>in</CODE> - the input stream to read from<DD><CODE>n</CODE> - the number of bytes to skip 701 <DT><B>Throws:</B> 702 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/EOFException.html?is-external=true" title="class or interface in java.io">EOFException</A></CODE> - if this stream reaches the end before skipping all 703 the bytes 704 <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> - if an I/O error occurs, or the stream does not 705 support skipping</DL> 706 </DD> 707 </DL> 708 <HR> 709 710 <A NAME="readBytes(com.google.common.io.InputSupplier, com.google.common.io.ByteProcessor)"><!-- --></A><H3> 711 readBytes</H3> 712 <PRE> 713 public static <T> T <B>readBytes</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier, 714 <A HREF="../../../../com/google/common/io/ByteProcessor.html" title="interface in com.google.common.io">ByteProcessor</A><T> processor) 715 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> 716 <DL> 717 <DD>Process the bytes of a supplied stream 718 <P> 719 <DD><DL> 720 <DT><B>Parameters:</B><DD><CODE>supplier</CODE> - the input stream factory<DD><CODE>processor</CODE> - the object to which to pass the bytes of the stream 721 <DT><B>Returns:</B><DD>the result of the byte processor 722 <DT><B>Throws:</B> 723 <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> - if an I/O error occurs</DL> 724 </DD> 725 </DL> 726 <HR> 727 728 <A NAME="getChecksum(com.google.common.io.InputSupplier, java.util.zip.Checksum)"><!-- --></A><H3> 729 getChecksum</H3> 730 <PRE> 731 public static long <B>getChecksum</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier, 732 <A HREF="http://java.sun.com/javase/6/docs/api/java/util/zip/Checksum.html?is-external=true" title="class or interface in java.util.zip">Checksum</A> checksum) 733 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> 734 <DL> 735 <DD>Computes and returns the checksum value for a supplied input stream. 736 The checksum object is reset when this method returns successfully. 737 <P> 738 <DD><DL> 739 <DT><B>Parameters:</B><DD><CODE>supplier</CODE> - the input stream factory<DD><CODE>checksum</CODE> - the checksum object 740 <DT><B>Returns:</B><DD>the result of <A HREF="http://java.sun.com/javase/6/docs/api/java/util/zip/Checksum.html?is-external=true#getValue()" title="class or interface in java.util.zip"><CODE>Checksum.getValue()</CODE></A> after updating the 741 checksum object with all of the bytes in the stream 742 <DT><B>Throws:</B> 743 <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> - if an I/O error occurs</DL> 744 </DD> 745 </DL> 746 <HR> 747 748 <A NAME="getDigest(com.google.common.io.InputSupplier, java.security.MessageDigest)"><!-- --></A><H3> 749 getDigest</H3> 750 <PRE> 751 public static byte[] <B>getDigest</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier, 752 <A HREF="http://java.sun.com/javase/6/docs/api/java/security/MessageDigest.html?is-external=true" title="class or interface in java.security">MessageDigest</A> md) 753 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> 754 <DL> 755 <DD>Computes and returns the digest value for a supplied input stream. 756 The digest object is reset when this method returns successfully. 757 <P> 758 <DD><DL> 759 <DT><B>Parameters:</B><DD><CODE>supplier</CODE> - the input stream factory<DD><CODE>md</CODE> - the digest object 760 <DT><B>Returns:</B><DD>the result of <A HREF="http://java.sun.com/javase/6/docs/api/java/security/MessageDigest.html?is-external=true#digest()" title="class or interface in java.security"><CODE>MessageDigest.digest()</CODE></A> after updating the 761 digest object with all of the bytes in the stream 762 <DT><B>Throws:</B> 763 <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> - if an I/O error occurs</DL> 764 </DD> 765 </DL> 766 <HR> 767 768 <A NAME="read(java.io.InputStream, byte[], int, int)"><!-- --></A><H3> 769 read</H3> 770 <PRE> 771 public static int <B>read</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A> in, 772 byte[] b, 773 int off, 774 int len) 775 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> 776 <DL> 777 <DD>Reads some bytes from an input stream and stores them into the buffer array 778 <code>b</code>. This method blocks until <code>len</code> bytes of input data have 779 been read into the array, or end of file is detected. The number of bytes 780 read is returned, possibly zero. Does not close the stream. 781 782 <p>A caller can detect EOF if the number of bytes read is less than 783 <code>len</code>. All subsequent calls on the same stream will return zero. 784 785 <p>If <code>b</code> is null, a <code>NullPointerException</code> is thrown. If 786 <code>off</code> is negative, or <code>len</code> is negative, or <code>off+len</code> is 787 greater than the length of the array <code>b</code>, then an 788 <code>IndexOutOfBoundsException</code> is thrown. If <code>len</code> is zero, then 789 no bytes are read. Otherwise, the first byte read is stored into element 790 <code>b[off]</code>, the next one into <code>b[off+1]</code>, and so on. The number 791 of bytes read is, at most, equal to <code>len</code>. 792 <P> 793 <DD><DL> 794 <DT><B>Parameters:</B><DD><CODE>in</CODE> - the input stream to read from<DD><CODE>b</CODE> - the buffer into which the data is read<DD><CODE>off</CODE> - an int specifying the offset into the data<DD><CODE>len</CODE> - an int specifying the number of bytes to read 795 <DT><B>Returns:</B><DD>the number of bytes read 796 <DT><B>Throws:</B> 797 <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> - if an I/O error occurs</DL> 798 </DD> 799 </DL> 800 <HR> 801 802 <A NAME="slice(com.google.common.io.InputSupplier, long, long)"><!-- --></A><H3> 803 slice</H3> 804 <PRE> 805 public static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> <B>slice</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> supplier, 806 long offset, 807 long length)</PRE> 808 <DL> 809 <DD>Returns an <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io"><CODE>InputSupplier</CODE></A> that returns input streams from the 810 an underlying supplier, where each stream starts at the given 811 offset and is limited to the specified number of bytes. 812 <P> 813 <DD><DL> 814 <DT><B>Parameters:</B><DD><CODE>supplier</CODE> - the supplier from which to get the raw streams<DD><CODE>offset</CODE> - the offset in bytes into the underlying stream where 815 the returned streams will start<DD><CODE>length</CODE> - the maximum length of the returned streams 816 <DT><B>Throws:</B> 817 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalArgumentException.html?is-external=true" title="class or interface in java.lang">IllegalArgumentException</A></CODE> - if offset or length are negative</DL> 818 </DD> 819 </DL> 820 <HR> 821 822 <A NAME="join(java.lang.Iterable)"><!-- --></A><H3> 823 join</H3> 824 <PRE> 825 public static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> <B>join</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Iterable.html?is-external=true" title="class or interface in java.lang">Iterable</A><? extends <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>>> suppliers)</PRE> 826 <DL> 827 <DD>Joins multiple <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io"><CODE>InputStream</CODE></A> suppliers into a single supplier. 828 Streams returned from the supplier will contain the concatenated data from 829 the streams of the underlying suppliers. 830 831 <p>Only one underlying input stream will be open at a time. Closing the 832 joined stream will close the open underlying stream. 833 834 <p>Reading from the joined stream will throw a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/NullPointerException.html?is-external=true" title="class or interface in java.lang"><CODE>NullPointerException</CODE></A> 835 if any of the suppliers are null or return null. 836 <P> 837 <DD><DL> 838 <DT><B>Parameters:</B><DD><CODE>suppliers</CODE> - the suppliers to concatenate 839 <DT><B>Returns:</B><DD>a supplier that will return a stream containing the concatenated 840 stream data</DL> 841 </DD> 842 </DL> 843 <HR> 844 845 <A NAME="join(com.google.common.io.InputSupplier...)"><!-- --></A><H3> 846 join</H3> 847 <PRE> 848 public static <A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>> <B>join</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><? extends <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStream.html?is-external=true" title="class or interface in java.io">InputStream</A>>... suppliers)</PRE> 849 <DL> 850 <DD>Varargs form of <A HREF="../../../../com/google/common/io/ByteStreams.html#join(java.lang.Iterable)"><CODE>join(Iterable)</CODE></A>. 851 <P> 852 <DD><DL> 853 </DL> 854 </DD> 855 </DL> 856 <!-- ========= END OF CLASS DATA ========= --> 857 <HR> 858 859 860 <!-- ======= START OF BOTTOM NAVBAR ====== --> 861 <A NAME="navbar_bottom"><!-- --></A> 862 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 863 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 864 <TR> 865 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 866 <A NAME="navbar_bottom_firstrow"><!-- --></A> 867 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 868 <TR ALIGN="center" VALIGN="top"> 869 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 870 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 871 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 872 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/ByteStreams.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 873 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 874 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 875 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 876 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 877 </TR> 878 </TABLE> 879 </TD> 880 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 881 </EM> 882 </TD> 883 </TR> 884 885 <TR> 886 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 887 <A HREF="../../../../com/google/common/io/ByteProcessor.html" title="interface in com.google.common.io"><B>PREV CLASS</B></A> 888 <A HREF="../../../../com/google/common/io/CharStreams.html" title="class in com.google.common.io"><B>NEXT CLASS</B></A></FONT></TD> 889 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 890 <A HREF="../../../../index.html?com/google/common/io/ByteStreams.html" target="_top"><B>FRAMES</B></A> 891 <A HREF="ByteStreams.html" target="_top"><B>NO FRAMES</B></A> 892 <SCRIPT type="text/javascript"> 893 <!-- 894 if(window==top) { 895 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 896 } 897 //--> 898 </SCRIPT> 899 <NOSCRIPT> 900 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 901 </NOSCRIPT> 902 903 904 </FONT></TD> 905 </TR> 906 <TR> 907 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 908 SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 909 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 910 DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 911 </TR> 912 </TABLE> 913 <A NAME="skip-navbar_bottom"></A> 914 <!-- ======== END OF BOTTOM NAVBAR ======= --> 915 916 <HR> 917 918 </BODY> 919 </HTML> 920