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 Files (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="Files (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/Files.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/FileBackedOutputStream.html" title="class in com.google.common.io"><B>PREV CLASS</B></A> 59 <A HREF="../../../../com/google/common/io/Flushables.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/Files.html" target="_top"><B>FRAMES</B></A> 62 <A HREF="Files.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 Files</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.Files</B> 97 </PRE> 98 <HR> 99 <DL> 100 <DT><PRE>public final class <B>Files</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 files. 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 void</CODE></FONT></TD> 131 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#append(java.lang.CharSequence, java.io.File, java.nio.charset.Charset)">append</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</A> from, 132 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to, 133 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 134 135 <BR> 136 Appends a character sequence (such as a string) to a file using the given 137 character set.</TD> 138 </TR> 139 <TR BGCOLOR="white" CLASS="TableRowColor"> 140 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 141 <CODE>static void</CODE></FONT></TD> 142 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#copy(java.io.File, java.nio.charset.Charset, java.lang.Appendable)">copy</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 143 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset, 144 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Appendable.html?is-external=true" title="class or interface in java.lang">Appendable</A> to)</CODE> 145 146 <BR> 147 Copies all characters from a file to an appendable object, 148 using the given character set.</TD> 149 </TR> 150 <TR BGCOLOR="white" CLASS="TableRowColor"> 151 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 152 <CODE>static 153 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 154 <TR ALIGN="right" VALIGN=""> 155 <TD NOWRAP><FONT SIZE="-1"> 156 <CODE><W extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Appendable.html?is-external=true" title="class or interface in java.lang">Appendable</A> & <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>> 157 <BR> 158 void</CODE></FONT></TD> 159 </TR> 160 </TABLE> 161 </CODE></FONT></TD> 162 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#copy(java.io.File, java.nio.charset.Charset, com.google.common.io.OutputSupplier)">copy</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 163 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset, 164 <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><W> to)</CODE> 165 166 <BR> 167 Copies all characters from a file to a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Appendable.html?is-external=true" title="class or interface in java.lang"><CODE>Appendable</CODE></A> & 168 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io"><CODE>Closeable</CODE></A> object supplied by a factory, using the given 169 character set.</TD> 170 </TR> 171 <TR BGCOLOR="white" CLASS="TableRowColor"> 172 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 173 <CODE>static void</CODE></FONT></TD> 174 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#copy(java.io.File, java.io.File)">copy</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 175 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to)</CODE> 176 177 <BR> 178 Copies all the bytes from one file to another.</TD> 179 </TR> 180 <TR BGCOLOR="white" CLASS="TableRowColor"> 181 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 182 <CODE>static void</CODE></FONT></TD> 183 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#copy(java.io.File, java.io.OutputStream)">copy</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 184 <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> 185 186 <BR> 187 Copies all bytes from a file to an output stream.</TD> 188 </TR> 189 <TR BGCOLOR="white" CLASS="TableRowColor"> 190 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 191 <CODE>static void</CODE></FONT></TD> 192 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#copy(java.io.File, com.google.common.io.OutputSupplier)">copy</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 193 <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> 194 195 <BR> 196 Copies all bytes from a file to an <A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io"><CODE>OutputStream</CODE></A> supplied by 197 a factory.</TD> 198 </TR> 199 <TR BGCOLOR="white" CLASS="TableRowColor"> 200 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 201 <CODE>static void</CODE></FONT></TD> 202 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#copy(com.google.common.io.InputSupplier, java.io.File)">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, 203 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to)</CODE> 204 205 <BR> 206 Copies to a file all bytes from an <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> supplied by a 207 factory.</TD> 208 </TR> 209 <TR BGCOLOR="white" CLASS="TableRowColor"> 210 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 211 <CODE>static 212 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 213 <TR ALIGN="right" VALIGN=""> 214 <TD NOWRAP><FONT SIZE="-1"> 215 <CODE><R extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Readable.html?is-external=true" title="class or interface in java.lang">Readable</A> & <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>> 216 <BR> 217 void</CODE></FONT></TD> 218 </TR> 219 </TABLE> 220 </CODE></FONT></TD> 221 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#copy(com.google.common.io.InputSupplier, java.io.File, java.nio.charset.Charset)">copy</A></B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><R> from, 222 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to, 223 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 224 225 <BR> 226 Copies to a file all characters from a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Readable.html?is-external=true" title="class or interface in java.lang"><CODE>Readable</CODE></A> and 227 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io"><CODE>Closeable</CODE></A> object supplied by a factory, using the given 228 character set.</TD> 229 </TR> 230 <TR BGCOLOR="white" CLASS="TableRowColor"> 231 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 232 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A></CODE></FONT></TD> 233 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#createTempDir()">createTempDir</A></B>()</CODE> 234 235 <BR> 236 Atomically creates a new directory somewhere beneath the system's 237 temporary directory (as defined by the <code>java.io.tmpdir</code> system 238 property), and returns its name.</TD> 239 </TR> 240 <TR BGCOLOR="white" CLASS="TableRowColor"> 241 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 242 <CODE>static void</CODE></FONT></TD> 243 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#deleteDirectoryContents(java.io.File)">deleteDirectoryContents</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> directory)</CODE> 244 245 <BR> 246 Deletes all the files within a directory.</TD> 247 </TR> 248 <TR BGCOLOR="white" CLASS="TableRowColor"> 249 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 250 <CODE>static void</CODE></FONT></TD> 251 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#deleteRecursively(java.io.File)">deleteRecursively</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file)</CODE> 252 253 <BR> 254 Deletes a file or directory and all contents recursively.</TD> 255 </TR> 256 <TR BGCOLOR="white" CLASS="TableRowColor"> 257 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 258 <CODE>static boolean</CODE></FONT></TD> 259 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#equal(java.io.File, java.io.File)">equal</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file1, 260 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file2)</CODE> 261 262 <BR> 263 Returns true if the files contains the same bytes.</TD> 264 </TR> 265 <TR BGCOLOR="white" CLASS="TableRowColor"> 266 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 267 <CODE>static long</CODE></FONT></TD> 268 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#getChecksum(java.io.File, java.util.zip.Checksum)">getChecksum</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 269 <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> 270 271 <BR> 272 Computes and returns the checksum value for a file.</TD> 273 </TR> 274 <TR BGCOLOR="white" CLASS="TableRowColor"> 275 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 276 <CODE>static byte[]</CODE></FONT></TD> 277 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#getDigest(java.io.File, java.security.MessageDigest)">getDigest</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 278 <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> 279 280 <BR> 281 Computes and returns the digest value for a file.</TD> 282 </TR> 283 <TR BGCOLOR="white" CLASS="TableRowColor"> 284 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 285 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/MappedByteBuffer.html?is-external=true" title="class or interface in java.nio">MappedByteBuffer</A></CODE></FONT></TD> 286 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#map(java.io.File)">map</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file)</CODE> 287 288 <BR> 289 Fully maps a file read-only in to memory as per 290 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long)</CODE></A>.</TD> 291 </TR> 292 <TR BGCOLOR="white" CLASS="TableRowColor"> 293 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 294 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/MappedByteBuffer.html?is-external=true" title="class or interface in java.nio">MappedByteBuffer</A></CODE></FONT></TD> 295 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#map(java.io.File, java.nio.channels.FileChannel.MapMode)">map</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 296 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true" title="class or interface in java.nio.channels">FileChannel.MapMode</A> mode)</CODE> 297 298 <BR> 299 Fully maps a file in to memory as per 300 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long)</CODE></A> 301 using the requested <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true" title="class or interface in java.nio.channels"><CODE>FileChannel.MapMode</CODE></A>.</TD> 302 </TR> 303 <TR BGCOLOR="white" CLASS="TableRowColor"> 304 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 305 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/MappedByteBuffer.html?is-external=true" title="class or interface in java.nio">MappedByteBuffer</A></CODE></FONT></TD> 306 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#map(java.io.File, java.nio.channels.FileChannel.MapMode, long)">map</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 307 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true" title="class or interface in java.nio.channels">FileChannel.MapMode</A> mode, 308 long size)</CODE> 309 310 <BR> 311 Maps a file in to memory as per 312 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long)</CODE></A> 313 using the requested <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true" title="class or interface in java.nio.channels"><CODE>FileChannel.MapMode</CODE></A>.</TD> 314 </TR> 315 <TR BGCOLOR="white" CLASS="TableRowColor"> 316 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 317 <CODE>static void</CODE></FONT></TD> 318 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#move(java.io.File, java.io.File)">move</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 319 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to)</CODE> 320 321 <BR> 322 Moves the file from one path to another.</TD> 323 </TR> 324 <TR BGCOLOR="white" CLASS="TableRowColor"> 325 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 326 <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/FileInputStream.html?is-external=true" title="class or interface in java.io">FileInputStream</A>></CODE></FONT></TD> 327 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#newInputStreamSupplier(java.io.File)">newInputStreamSupplier</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file)</CODE> 328 329 <BR> 330 Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileInputStream.html?is-external=true" title="class or interface in java.io"><CODE>FileInputStream</CODE></A> 331 that read from a file.</TD> 332 </TR> 333 <TR BGCOLOR="white" CLASS="TableRowColor"> 334 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 335 <CODE>static <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html?is-external=true" title="class or interface in java.io">FileOutputStream</A>></CODE></FONT></TD> 336 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#newOutputStreamSupplier(java.io.File)">newOutputStreamSupplier</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file)</CODE> 337 338 <BR> 339 Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html?is-external=true" title="class or interface in java.io"><CODE>FileOutputStream</CODE></A> 340 that write to a file.</TD> 341 </TR> 342 <TR BGCOLOR="white" CLASS="TableRowColor"> 343 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 344 <CODE>static <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html?is-external=true" title="class or interface in java.io">FileOutputStream</A>></CODE></FONT></TD> 345 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#newOutputStreamSupplier(java.io.File, boolean)">newOutputStreamSupplier</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 346 boolean append)</CODE> 347 348 <BR> 349 Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html?is-external=true" title="class or interface in java.io"><CODE>FileOutputStream</CODE></A> 350 that write to or append to a file.</TD> 351 </TR> 352 <TR BGCOLOR="white" CLASS="TableRowColor"> 353 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 354 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html?is-external=true" title="class or interface in java.io">BufferedReader</A></CODE></FONT></TD> 355 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#newReader(java.io.File, java.nio.charset.Charset)">newReader</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 356 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 357 358 <BR> 359 Returns a buffered reader that reads from a file using the given 360 character set.</TD> 361 </TR> 362 <TR BGCOLOR="white" CLASS="TableRowColor"> 363 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 364 <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/InputStreamReader.html?is-external=true" title="class or interface in java.io">InputStreamReader</A>></CODE></FONT></TD> 365 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#newReaderSupplier(java.io.File, java.nio.charset.Charset)">newReaderSupplier</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 366 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 367 368 <BR> 369 Returns a factory that will supply instances of 370 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStreamReader.html?is-external=true" title="class or interface in java.io"><CODE>InputStreamReader</CODE></A> that read a file using the given character set.</TD> 371 </TR> 372 <TR BGCOLOR="white" CLASS="TableRowColor"> 373 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 374 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/io/BufferedWriter.html?is-external=true" title="class or interface in java.io">BufferedWriter</A></CODE></FONT></TD> 375 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#newWriter(java.io.File, java.nio.charset.Charset)">newWriter</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 376 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 377 378 <BR> 379 Returns a buffered writer that writes to a file using the given 380 character set.</TD> 381 </TR> 382 <TR BGCOLOR="white" CLASS="TableRowColor"> 383 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 384 <CODE>static <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html?is-external=true" title="class or interface in java.io">OutputStreamWriter</A>></CODE></FONT></TD> 385 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#newWriterSupplier(java.io.File, java.nio.charset.Charset)">newWriterSupplier</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 386 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 387 388 <BR> 389 Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html?is-external=true" title="class or interface in java.io"><CODE>OutputStreamWriter</CODE></A> 390 that write to a file using the given character set.</TD> 391 </TR> 392 <TR BGCOLOR="white" CLASS="TableRowColor"> 393 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 394 <CODE>static <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html?is-external=true" title="class or interface in java.io">OutputStreamWriter</A>></CODE></FONT></TD> 395 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#newWriterSupplier(java.io.File, java.nio.charset.Charset, boolean)">newWriterSupplier</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 396 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset, 397 boolean append)</CODE> 398 399 <BR> 400 Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html?is-external=true" title="class or interface in java.io"><CODE>OutputStreamWriter</CODE></A> 401 that write to or append to a file using the given character set.</TD> 402 </TR> 403 <TR BGCOLOR="white" CLASS="TableRowColor"> 404 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 405 <CODE>static 406 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 407 <TR ALIGN="right" VALIGN=""> 408 <TD NOWRAP><FONT SIZE="-1"> 409 <CODE><T> T</CODE></FONT></TD> 410 </TR> 411 </TABLE> 412 </CODE></FONT></TD> 413 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#readBytes(java.io.File, com.google.common.io.ByteProcessor)">readBytes</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 414 <A HREF="../../../../com/google/common/io/ByteProcessor.html" title="interface in com.google.common.io">ByteProcessor</A><T> processor)</CODE> 415 416 <BR> 417 Process the bytes of a file.</TD> 418 </TR> 419 <TR BGCOLOR="white" CLASS="TableRowColor"> 420 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 421 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD> 422 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#readFirstLine(java.io.File, java.nio.charset.Charset)">readFirstLine</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 423 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 424 425 <BR> 426 Reads the first line from a file.</TD> 427 </TR> 428 <TR BGCOLOR="white" CLASS="TableRowColor"> 429 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 430 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>></CODE></FONT></TD> 431 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#readLines(java.io.File, java.nio.charset.Charset)">readLines</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 432 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 433 434 <BR> 435 Reads all of the lines from a file.</TD> 436 </TR> 437 <TR BGCOLOR="white" CLASS="TableRowColor"> 438 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 439 <CODE>static 440 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" SUMMARY=""> 441 <TR ALIGN="right" VALIGN=""> 442 <TD NOWRAP><FONT SIZE="-1"> 443 <CODE><T> T</CODE></FONT></TD> 444 </TR> 445 </TABLE> 446 </CODE></FONT></TD> 447 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#readLines(java.io.File, java.nio.charset.Charset, com.google.common.io.LineProcessor)">readLines</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 448 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset, 449 <A HREF="../../../../com/google/common/io/LineProcessor.html" title="interface in com.google.common.io">LineProcessor</A><T> callback)</CODE> 450 451 <BR> 452 Streams lines from a <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io"><CODE>File</CODE></A>, stopping when our callback returns 453 false, or we have read all of the lines.</TD> 454 </TR> 455 <TR BGCOLOR="white" CLASS="TableRowColor"> 456 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 457 <CODE>static byte[]</CODE></FONT></TD> 458 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#toByteArray(java.io.File)">toByteArray</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file)</CODE> 459 460 <BR> 461 Reads all bytes from a file into a byte array.</TD> 462 </TR> 463 <TR BGCOLOR="white" CLASS="TableRowColor"> 464 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 465 <CODE>static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A></CODE></FONT></TD> 466 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#toString(java.io.File, java.nio.charset.Charset)">toString</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 467 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 468 469 <BR> 470 Reads all characters from a file into a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang"><CODE>String</CODE></A>, using the given 471 character set.</TD> 472 </TR> 473 <TR BGCOLOR="white" CLASS="TableRowColor"> 474 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 475 <CODE>static void</CODE></FONT></TD> 476 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#touch(java.io.File)">touch</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file)</CODE> 477 478 <BR> 479 Creates an empty file or updates the last updated timestamp on the 480 same as the unix command of the same name.</TD> 481 </TR> 482 <TR BGCOLOR="white" CLASS="TableRowColor"> 483 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 484 <CODE>static void</CODE></FONT></TD> 485 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#write(byte[], java.io.File)">write</A></B>(byte[] from, 486 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to)</CODE> 487 488 <BR> 489 Overwrites a file with the contents of a byte array.</TD> 490 </TR> 491 <TR BGCOLOR="white" CLASS="TableRowColor"> 492 <TD ALIGN="right" VALIGN="top" WIDTH="1%"><FONT SIZE="-1"> 493 <CODE>static void</CODE></FONT></TD> 494 <TD><CODE><B><A HREF="../../../../com/google/common/io/Files.html#write(java.lang.CharSequence, java.io.File, java.nio.charset.Charset)">write</A></B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</A> from, 495 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to, 496 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</CODE> 497 498 <BR> 499 Writes a character sequence (such as a string) to a file using the given 500 character set.</TD> 501 </TR> 502 </TABLE> 503 <A NAME="methods_inherited_from_class_java.lang.Object"><!-- --></A> 504 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 505 <TR BGCOLOR="#EEEEFF" CLASS="TableSubHeadingColor"> 506 <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> 507 </TR> 508 <TR BGCOLOR="white" CLASS="TableRowColor"> 509 <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> 510 </TR> 511 </TABLE> 512 513 <P> 514 515 <!-- ============ METHOD DETAIL ========== --> 516 517 <A NAME="method_detail"><!-- --></A> 518 <TABLE BORDER="1" WIDTH="100%" CELLPADDING="3" CELLSPACING="0" SUMMARY=""> 519 <TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"> 520 <TH ALIGN="left" COLSPAN="1"><FONT SIZE="+2"> 521 <B>Method Detail</B></FONT></TH> 522 </TR> 523 </TABLE> 524 525 <A NAME="newReader(java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 526 newReader</H3> 527 <PRE> 528 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html?is-external=true" title="class or interface in java.io">BufferedReader</A> <B>newReader</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 529 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset) 530 throws <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileNotFoundException.html?is-external=true" title="class or interface in java.io">FileNotFoundException</A></PRE> 531 <DL> 532 <DD>Returns a buffered reader that reads from a file using the given 533 character set. 534 <P> 535 <DD><DL> 536 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read from<DD><CODE>charset</CODE> - the character set used when writing the file 537 <DT><B>Returns:</B><DD>the buffered reader 538 <DT><B>Throws:</B> 539 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileNotFoundException.html?is-external=true" title="class or interface in java.io">FileNotFoundException</A></CODE></DL> 540 </DD> 541 </DL> 542 <HR> 543 544 <A NAME="newWriter(java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 545 newWriter</H3> 546 <PRE> 547 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/io/BufferedWriter.html?is-external=true" title="class or interface in java.io">BufferedWriter</A> <B>newWriter</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 548 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset) 549 throws <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileNotFoundException.html?is-external=true" title="class or interface in java.io">FileNotFoundException</A></PRE> 550 <DL> 551 <DD>Returns a buffered writer that writes to a file using the given 552 character set. 553 <P> 554 <DD><DL> 555 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to write to<DD><CODE>charset</CODE> - the character set used when writing the file 556 <DT><B>Returns:</B><DD>the buffered writer 557 <DT><B>Throws:</B> 558 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileNotFoundException.html?is-external=true" title="class or interface in java.io">FileNotFoundException</A></CODE></DL> 559 </DD> 560 </DL> 561 <HR> 562 563 <A NAME="newInputStreamSupplier(java.io.File)"><!-- --></A><H3> 564 newInputStreamSupplier</H3> 565 <PRE> 566 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/FileInputStream.html?is-external=true" title="class or interface in java.io">FileInputStream</A>> <B>newInputStreamSupplier</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file)</PRE> 567 <DL> 568 <DD>Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileInputStream.html?is-external=true" title="class or interface in java.io"><CODE>FileInputStream</CODE></A> 569 that read from a file. 570 <P> 571 <DD><DL> 572 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read from 573 <DT><B>Returns:</B><DD>the factory</DL> 574 </DD> 575 </DL> 576 <HR> 577 578 <A NAME="newOutputStreamSupplier(java.io.File)"><!-- --></A><H3> 579 newOutputStreamSupplier</H3> 580 <PRE> 581 public static <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html?is-external=true" title="class or interface in java.io">FileOutputStream</A>> <B>newOutputStreamSupplier</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file)</PRE> 582 <DL> 583 <DD>Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html?is-external=true" title="class or interface in java.io"><CODE>FileOutputStream</CODE></A> 584 that write to a file. 585 <P> 586 <DD><DL> 587 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to write to 588 <DT><B>Returns:</B><DD>the factory</DL> 589 </DD> 590 </DL> 591 <HR> 592 593 <A NAME="newOutputStreamSupplier(java.io.File, boolean)"><!-- --></A><H3> 594 newOutputStreamSupplier</H3> 595 <PRE> 596 public static <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html?is-external=true" title="class or interface in java.io">FileOutputStream</A>> <B>newOutputStreamSupplier</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 597 boolean append)</PRE> 598 <DL> 599 <DD>Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileOutputStream.html?is-external=true" title="class or interface in java.io"><CODE>FileOutputStream</CODE></A> 600 that write to or append to a file. 601 <P> 602 <DD><DL> 603 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to write to<DD><CODE>append</CODE> - if true, the encoded characters will be appended to the file; 604 otherwise the file is overwritten 605 <DT><B>Returns:</B><DD>the factory</DL> 606 </DD> 607 </DL> 608 <HR> 609 610 <A NAME="newReaderSupplier(java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 611 newReaderSupplier</H3> 612 <PRE> 613 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/InputStreamReader.html?is-external=true" title="class or interface in java.io">InputStreamReader</A>> <B>newReaderSupplier</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 614 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</PRE> 615 <DL> 616 <DD>Returns a factory that will supply instances of 617 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/InputStreamReader.html?is-external=true" title="class or interface in java.io"><CODE>InputStreamReader</CODE></A> that read a file using the given character set. 618 <P> 619 <DD><DL> 620 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read from<DD><CODE>charset</CODE> - the character set used when reading the file 621 <DT><B>Returns:</B><DD>the factory</DL> 622 </DD> 623 </DL> 624 <HR> 625 626 <A NAME="newWriterSupplier(java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 627 newWriterSupplier</H3> 628 <PRE> 629 public static <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html?is-external=true" title="class or interface in java.io">OutputStreamWriter</A>> <B>newWriterSupplier</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 630 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset)</PRE> 631 <DL> 632 <DD>Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html?is-external=true" title="class or interface in java.io"><CODE>OutputStreamWriter</CODE></A> 633 that write to a file using the given character set. 634 <P> 635 <DD><DL> 636 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to write to<DD><CODE>charset</CODE> - the character set used when writing the file 637 <DT><B>Returns:</B><DD>the factory</DL> 638 </DD> 639 </DL> 640 <HR> 641 642 <A NAME="newWriterSupplier(java.io.File, java.nio.charset.Charset, boolean)"><!-- --></A><H3> 643 newWriterSupplier</H3> 644 <PRE> 645 public static <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html?is-external=true" title="class or interface in java.io">OutputStreamWriter</A>> <B>newWriterSupplier</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 646 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset, 647 boolean append)</PRE> 648 <DL> 649 <DD>Returns a factory that will supply instances of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStreamWriter.html?is-external=true" title="class or interface in java.io"><CODE>OutputStreamWriter</CODE></A> 650 that write to or append to a file using the given character set. 651 <P> 652 <DD><DL> 653 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to write to<DD><CODE>charset</CODE> - the character set used when writing the file<DD><CODE>append</CODE> - if true, the encoded characters will be appended to the file; 654 otherwise the file is overwritten 655 <DT><B>Returns:</B><DD>the factory</DL> 656 </DD> 657 </DL> 658 <HR> 659 660 <A NAME="toByteArray(java.io.File)"><!-- --></A><H3> 661 toByteArray</H3> 662 <PRE> 663 public static byte[] <B>toByteArray</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file) 664 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> 665 <DL> 666 <DD>Reads all bytes from a file into a byte array. 667 <P> 668 <DD><DL> 669 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read from 670 <DT><B>Returns:</B><DD>a byte array containing all the bytes from file 671 <DT><B>Throws:</B> 672 <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 the file is bigger than the largest 673 possible byte array (2^31 - 1) 674 <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> 675 </DD> 676 </DL> 677 <HR> 678 679 <A NAME="toString(java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 680 toString</H3> 681 <PRE> 682 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>toString</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 683 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset) 684 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> 685 <DL> 686 <DD>Reads all characters from a file into a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang"><CODE>String</CODE></A>, using the given 687 character set. 688 <P> 689 <DD><DL> 690 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read from<DD><CODE>charset</CODE> - the character set used when reading the file 691 <DT><B>Returns:</B><DD>a string containing all the characters from the file 692 <DT><B>Throws:</B> 693 <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> 694 </DD> 695 </DL> 696 <HR> 697 698 <A NAME="copy(com.google.common.io.InputSupplier, java.io.File)"><!-- --></A><H3> 699 copy</H3> 700 <PRE> 701 public static void <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, 702 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to) 703 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> 704 <DL> 705 <DD>Copies to a file all bytes from an <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> supplied by a 706 factory. 707 <P> 708 <DD><DL> 709 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the input factory<DD><CODE>to</CODE> - the destination file 710 <DT><B>Throws:</B> 711 <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> 712 </DD> 713 </DL> 714 <HR> 715 716 <A NAME="write(byte[], java.io.File)"><!-- --></A><H3> 717 write</H3> 718 <PRE> 719 public static void <B>write</B>(byte[] from, 720 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to) 721 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> 722 <DL> 723 <DD>Overwrites a file with the contents of a byte array. 724 <P> 725 <DD><DL> 726 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the bytes to write<DD><CODE>to</CODE> - the destination file 727 <DT><B>Throws:</B> 728 <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> 729 </DD> 730 </DL> 731 <HR> 732 733 <A NAME="copy(java.io.File, com.google.common.io.OutputSupplier)"><!-- --></A><H3> 734 copy</H3> 735 <PRE> 736 public static void <B>copy</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 737 <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) 738 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> 739 <DL> 740 <DD>Copies all bytes from a file to an <A HREF="http://java.sun.com/javase/6/docs/api/java/io/OutputStream.html?is-external=true" title="class or interface in java.io"><CODE>OutputStream</CODE></A> supplied by 741 a factory. 742 <P> 743 <DD><DL> 744 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the source file<DD><CODE>to</CODE> - the output factory 745 <DT><B>Throws:</B> 746 <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> 747 </DD> 748 </DL> 749 <HR> 750 751 <A NAME="copy(java.io.File, java.io.OutputStream)"><!-- --></A><H3> 752 copy</H3> 753 <PRE> 754 public static void <B>copy</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 755 <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) 756 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> 757 <DL> 758 <DD>Copies all bytes from a file to an output stream. 759 <P> 760 <DD><DL> 761 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the source file<DD><CODE>to</CODE> - the output 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="copy(java.io.File, java.io.File)"><!-- --></A><H3> 769 copy</H3> 770 <PRE> 771 public static void <B>copy</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 772 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to) 773 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> 774 <DL> 775 <DD>Copies all the bytes from one file to another. 776 . 777 <P> 778 <DD><DL> 779 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the source file<DD><CODE>to</CODE> - the destination file 780 <DT><B>Throws:</B> 781 <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> 782 </DD> 783 </DL> 784 <HR> 785 786 <A NAME="copy(com.google.common.io.InputSupplier, java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 787 copy</H3> 788 <PRE> 789 public static <R extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Readable.html?is-external=true" title="class or interface in java.lang">Readable</A> & <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>> void <B>copy</B>(<A HREF="../../../../com/google/common/io/InputSupplier.html" title="interface in com.google.common.io">InputSupplier</A><R> from, 790 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to, 791 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset) 792 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> 793 <DL> 794 <DD>Copies to a file all characters from a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Readable.html?is-external=true" title="class or interface in java.lang"><CODE>Readable</CODE></A> and 795 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io"><CODE>Closeable</CODE></A> object supplied by a factory, using the given 796 character set. 797 <P> 798 <DD><DL> 799 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the readable supplier<DD><CODE>to</CODE> - the destination file<DD><CODE>charset</CODE> - the character set used when writing the file 800 <DT><B>Throws:</B> 801 <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> 802 </DD> 803 </DL> 804 <HR> 805 806 <A NAME="write(java.lang.CharSequence, java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 807 write</H3> 808 <PRE> 809 public static void <B>write</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</A> from, 810 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to, 811 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset) 812 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> 813 <DL> 814 <DD>Writes a character sequence (such as a string) to a file using the given 815 character set. 816 <P> 817 <DD><DL> 818 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the character sequence to write<DD><CODE>to</CODE> - the destination file<DD><CODE>charset</CODE> - the character set used when writing the file 819 <DT><B>Throws:</B> 820 <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> 821 </DD> 822 </DL> 823 <HR> 824 825 <A NAME="append(java.lang.CharSequence, java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 826 append</H3> 827 <PRE> 828 public static void <B>append</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/CharSequence.html?is-external=true" title="class or interface in java.lang">CharSequence</A> from, 829 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to, 830 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset) 831 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> 832 <DL> 833 <DD>Appends a character sequence (such as a string) to a file using the given 834 character set. 835 <P> 836 <DD><DL> 837 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the character sequence to append<DD><CODE>to</CODE> - the destination file<DD><CODE>charset</CODE> - the character set used when writing the file 838 <DT><B>Throws:</B> 839 <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> 840 </DD> 841 </DL> 842 <HR> 843 844 <A NAME="copy(java.io.File, java.nio.charset.Charset, com.google.common.io.OutputSupplier)"><!-- --></A><H3> 845 copy</H3> 846 <PRE> 847 public static <W extends <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Appendable.html?is-external=true" title="class or interface in java.lang">Appendable</A> & <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>> void <B>copy</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 848 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset, 849 <A HREF="../../../../com/google/common/io/OutputSupplier.html" title="interface in com.google.common.io">OutputSupplier</A><W> to) 850 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> 851 <DL> 852 <DD>Copies all characters from a file to a <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Appendable.html?is-external=true" title="class or interface in java.lang"><CODE>Appendable</CODE></A> & 853 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/Closeable.html?is-external=true" title="class or interface in java.io"><CODE>Closeable</CODE></A> object supplied by a factory, using the given 854 character set. 855 <P> 856 <DD><DL> 857 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the source file<DD><CODE>charset</CODE> - the character set used when reading the file<DD><CODE>to</CODE> - the appendable supplier 858 <DT><B>Throws:</B> 859 <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> 860 </DD> 861 </DL> 862 <HR> 863 864 <A NAME="copy(java.io.File, java.nio.charset.Charset, java.lang.Appendable)"><!-- --></A><H3> 865 copy</H3> 866 <PRE> 867 public static void <B>copy</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 868 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset, 869 <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Appendable.html?is-external=true" title="class or interface in java.lang">Appendable</A> to) 870 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> 871 <DL> 872 <DD>Copies all characters from a file to an appendable object, 873 using the given character set. 874 <P> 875 <DD><DL> 876 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the source file<DD><CODE>charset</CODE> - the character set used when reading the file<DD><CODE>to</CODE> - the appendable object 877 <DT><B>Throws:</B> 878 <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> 879 </DD> 880 </DL> 881 <HR> 882 883 <A NAME="equal(java.io.File, java.io.File)"><!-- --></A><H3> 884 equal</H3> 885 <PRE> 886 public static boolean <B>equal</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file1, 887 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file2) 888 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> 889 <DL> 890 <DD>Returns true if the files contains the same bytes. 891 <P> 892 <DD><DL> 893 894 <DT><B>Throws:</B> 895 <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> 896 </DD> 897 </DL> 898 <HR> 899 900 <A NAME="createTempDir()"><!-- --></A><H3> 901 createTempDir</H3> 902 <PRE> 903 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> <B>createTempDir</B>()</PRE> 904 <DL> 905 <DD>Atomically creates a new directory somewhere beneath the system's 906 temporary directory (as defined by the <code>java.io.tmpdir</code> system 907 property), and returns its name. 908 909 <p>Use this method instead of <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true#createTempFile(java.lang.String, java.lang.String)" title="class or interface in java.io"><CODE>File.createTempFile(String, String)</CODE></A> 910 when you wish to create a directory, not a regular file. A common pitfall 911 is to call <code>createTempFile</code>, delete the file and create a 912 directory in its place, but this leads a race condition which can be 913 exploited to create security vulnerabilities, especially when executable 914 files are to be written into the directory. 915 916 <p>This method assumes that the temporary volume is writable, has free 917 inodes and free blocks, and that it will not be called thousands of times 918 per second. 919 <P> 920 <DD><DL> 921 922 <DT><B>Returns:</B><DD>the newly-created directory 923 <DT><B>Throws:</B> 924 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/lang/IllegalStateException.html?is-external=true" title="class or interface in java.lang">IllegalStateException</A></CODE> - if the directory could not be created</DL> 925 </DD> 926 </DL> 927 <HR> 928 929 <A NAME="touch(java.io.File)"><!-- --></A><H3> 930 touch</H3> 931 <PRE> 932 public static void <B>touch</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file) 933 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> 934 <DL> 935 <DD>Creates an empty file or updates the last updated timestamp on the 936 same as the unix command of the same name. 937 <P> 938 <DD><DL> 939 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to create or update 940 <DT><B>Throws:</B> 941 <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> 942 </DD> 943 </DL> 944 <HR> 945 946 <A NAME="move(java.io.File, java.io.File)"><!-- --></A><H3> 947 move</H3> 948 <PRE> 949 public static void <B>move</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> from, 950 <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> to) 951 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> 952 <DL> 953 <DD>Moves the file from one path to another. This method can rename a file or 954 move it to a different directory, like the Unix <code>mv</code> command. 955 <P> 956 <DD><DL> 957 <DT><B>Parameters:</B><DD><CODE>from</CODE> - the source file<DD><CODE>to</CODE> - the destination file 958 <DT><B>Throws:</B> 959 <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> 960 </DD> 961 </DL> 962 <HR> 963 964 <A NAME="deleteDirectoryContents(java.io.File)"><!-- --></A><H3> 965 deleteDirectoryContents</H3> 966 <PRE> 967 public static void <B>deleteDirectoryContents</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> directory) 968 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> 969 <DL> 970 <DD>Deletes all the files within a directory. Does not delete the 971 directory itself. 972 973 <p>If the file argument is a symbolic link or there is a symbolic 974 link in the path leading to the directory, this method will do 975 nothing. Symbolic links within the directory are not followed. 976 <P> 977 <DD><DL> 978 <DT><B>Parameters:</B><DD><CODE>directory</CODE> - the directory to delete the contents of 979 <DT><B>Throws:</B> 980 <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 the argument is not a directory 981 <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<DT><B>See Also:</B><DD><A HREF="../../../../com/google/common/io/Files.html#deleteRecursively(java.io.File)"><CODE>deleteRecursively(java.io.File)</CODE></A></DL> 982 </DD> 983 </DL> 984 <HR> 985 986 <A NAME="deleteRecursively(java.io.File)"><!-- --></A><H3> 987 deleteRecursively</H3> 988 <PRE> 989 public static void <B>deleteRecursively</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file) 990 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> 991 <DL> 992 <DD>Deletes a file or directory and all contents recursively. 993 994 <p>If the file argument is a symbolic link the link will be deleted 995 but not the target of the link. If the argument is a directory, 996 symbolic links within the directory will not be followed. 997 <P> 998 <DD><DL> 999 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to delete 1000 <DT><B>Throws:</B> 1001 <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<DT><B>See Also:</B><DD><A HREF="../../../../com/google/common/io/Files.html#deleteDirectoryContents(java.io.File)"><CODE>deleteDirectoryContents(java.io.File)</CODE></A></DL> 1002 </DD> 1003 </DL> 1004 <HR> 1005 1006 <A NAME="readFirstLine(java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 1007 readFirstLine</H3> 1008 <PRE> 1009 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A> <B>readFirstLine</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 1010 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset) 1011 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> 1012 <DL> 1013 <DD>Reads the first line from a file. The line does not include 1014 line-termination characters, but does include other leading and 1015 trailing whitespace. 1016 <P> 1017 <DD><DL> 1018 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read from<DD><CODE>charset</CODE> - the character set used when writing the file 1019 <DT><B>Returns:</B><DD>the first line, or null if the file is empty 1020 <DT><B>Throws:</B> 1021 <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> 1022 </DD> 1023 </DL> 1024 <HR> 1025 1026 <A NAME="readLines(java.io.File, java.nio.charset.Charset)"><!-- --></A><H3> 1027 readLines</H3> 1028 <PRE> 1029 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util">List</A><<A HREF="http://java.sun.com/javase/6/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang">String</A>> <B>readLines</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 1030 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset) 1031 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> 1032 <DL> 1033 <DD>Reads all of the lines from a file. The lines do not include 1034 line-termination characters, but do include other leading and 1035 trailing whitespace. 1036 <P> 1037 <DD><DL> 1038 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read from<DD><CODE>charset</CODE> - the character set used when writing the file 1039 <DT><B>Returns:</B><DD>a mutable <A HREF="http://java.sun.com/javase/6/docs/api/java/util/List.html?is-external=true" title="class or interface in java.util"><CODE>List</CODE></A> containing all the lines 1040 <DT><B>Throws:</B> 1041 <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> 1042 </DD> 1043 </DL> 1044 <HR> 1045 1046 <A NAME="readLines(java.io.File, java.nio.charset.Charset, com.google.common.io.LineProcessor)"><!-- --></A><H3> 1047 readLines</H3> 1048 <PRE> 1049 public static <T> T <B>readLines</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 1050 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/charset/Charset.html?is-external=true" title="class or interface in java.nio.charset">Charset</A> charset, 1051 <A HREF="../../../../com/google/common/io/LineProcessor.html" title="interface in com.google.common.io">LineProcessor</A><T> callback) 1052 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> 1053 <DL> 1054 <DD>Streams lines from a <A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io"><CODE>File</CODE></A>, stopping when our callback returns 1055 false, or we have read all of the lines. 1056 <P> 1057 <DD><DL> 1058 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read from<DD><CODE>charset</CODE> - the character set used when writing the file<DD><CODE>callback</CODE> - the <A HREF="../../../../com/google/common/io/LineProcessor.html" title="interface in com.google.common.io"><CODE>LineProcessor</CODE></A> to use to handle the lines 1059 <DT><B>Returns:</B><DD>the output of processing the lines 1060 <DT><B>Throws:</B> 1061 <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> 1062 </DD> 1063 </DL> 1064 <HR> 1065 1066 <A NAME="readBytes(java.io.File, com.google.common.io.ByteProcessor)"><!-- --></A><H3> 1067 readBytes</H3> 1068 <PRE> 1069 public static <T> T <B>readBytes</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 1070 <A HREF="../../../../com/google/common/io/ByteProcessor.html" title="interface in com.google.common.io">ByteProcessor</A><T> processor) 1071 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> 1072 <DL> 1073 <DD>Process the bytes of a file. 1074 1075 <p>(If this seems too complicated, maybe you're looking for 1076 <A HREF="../../../../com/google/common/io/Files.html#toByteArray(java.io.File)"><CODE>toByteArray(java.io.File)</CODE></A>.) 1077 <P> 1078 <DD><DL> 1079 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read<DD><CODE>processor</CODE> - the object to which the bytes of the file are passed. 1080 <DT><B>Returns:</B><DD>the result of the byte processor 1081 <DT><B>Throws:</B> 1082 <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> 1083 </DD> 1084 </DL> 1085 <HR> 1086 1087 <A NAME="getChecksum(java.io.File, java.util.zip.Checksum)"><!-- --></A><H3> 1088 getChecksum</H3> 1089 <PRE> 1090 public static long <B>getChecksum</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 1091 <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) 1092 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> 1093 <DL> 1094 <DD>Computes and returns the checksum value for a file. 1095 The checksum object is reset when this method returns successfully. 1096 <P> 1097 <DD><DL> 1098 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read<DD><CODE>checksum</CODE> - the checksum object 1099 <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 1100 checksum object with all of the bytes in the file 1101 <DT><B>Throws:</B> 1102 <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> 1103 </DD> 1104 </DL> 1105 <HR> 1106 1107 <A NAME="getDigest(java.io.File, java.security.MessageDigest)"><!-- --></A><H3> 1108 getDigest</H3> 1109 <PRE> 1110 public static byte[] <B>getDigest</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 1111 <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) 1112 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> 1113 <DL> 1114 <DD>Computes and returns the digest value for a file. 1115 The digest object is reset when this method returns successfully. 1116 <P> 1117 <DD><DL> 1118 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to read<DD><CODE>md</CODE> - the digest object 1119 <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 1120 digest object with all of the bytes in this file 1121 <DT><B>Throws:</B> 1122 <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> 1123 </DD> 1124 </DL> 1125 <HR> 1126 1127 <A NAME="map(java.io.File)"><!-- --></A><H3> 1128 map</H3> 1129 <PRE> 1130 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/MappedByteBuffer.html?is-external=true" title="class or interface in java.nio">MappedByteBuffer</A> <B>map</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file) 1131 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> 1132 <DL> 1133 <DD>Fully maps a file read-only in to memory as per 1134 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long)</CODE></A>. 1135 1136 <p>Files are mapped from offset 0 to its length. 1137 1138 <p>This only works for files <= <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Integer.MAX_VALUE</CODE></A> bytes. 1139 <P> 1140 <DD><DL> 1141 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to map 1142 <DT><B>Returns:</B><DD>a read-only buffer reflecting <code>file</code> 1143 <DT><B>Throws:</B> 1144 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileNotFoundException.html?is-external=true" title="class or interface in java.io">FileNotFoundException</A></CODE> - if the <code>file</code> does not exist 1145 <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<DT><B>Since:</B></DT> 1146 <DD>2010.01.04 <b>tentative</b></DD> 1147 <DT><B>See Also:</B><DD><A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(MapMode, long, long)</CODE></A></DL> 1148 </DD> 1149 </DL> 1150 <HR> 1151 1152 <A NAME="map(java.io.File, java.nio.channels.FileChannel.MapMode)"><!-- --></A><H3> 1153 map</H3> 1154 <PRE> 1155 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/MappedByteBuffer.html?is-external=true" title="class or interface in java.nio">MappedByteBuffer</A> <B>map</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 1156 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true" title="class or interface in java.nio.channels">FileChannel.MapMode</A> mode) 1157 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> 1158 <DL> 1159 <DD>Fully maps a file in to memory as per 1160 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long)</CODE></A> 1161 using the requested <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true" title="class or interface in java.nio.channels"><CODE>FileChannel.MapMode</CODE></A>. 1162 1163 <p>Files are mapped from offset 0 to its length. 1164 1165 <p>This only works for files <= <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Integer.MAX_VALUE</CODE></A> bytes. 1166 <P> 1167 <DD><DL> 1168 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to map<DD><CODE>mode</CODE> - the mode to use when mapping <code>file</code> 1169 <DT><B>Returns:</B><DD>a buffer reflecting <code>file</code> 1170 <DT><B>Throws:</B> 1171 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileNotFoundException.html?is-external=true" title="class or interface in java.io">FileNotFoundException</A></CODE> - if the <code>file</code> does not exist 1172 <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<DT><B>Since:</B></DT> 1173 <DD>2010.01.04 <b>tentative</b></DD> 1174 <DT><B>See Also:</B><DD><A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(MapMode, long, long)</CODE></A></DL> 1175 </DD> 1176 </DL> 1177 <HR> 1178 1179 <A NAME="map(java.io.File, java.nio.channels.FileChannel.MapMode, long)"><!-- --></A><H3> 1180 map</H3> 1181 <PRE> 1182 public static <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/MappedByteBuffer.html?is-external=true" title="class or interface in java.nio">MappedByteBuffer</A> <B>map</B>(<A HREF="http://java.sun.com/javase/6/docs/api/java/io/File.html?is-external=true" title="class or interface in java.io">File</A> file, 1183 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true" title="class or interface in java.nio.channels">FileChannel.MapMode</A> mode, 1184 long size) 1185 throws <A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileNotFoundException.html?is-external=true" title="class or interface in java.io">FileNotFoundException</A>, 1186 <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> 1187 <DL> 1188 <DD>Maps a file in to memory as per 1189 <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long)</CODE></A> 1190 using the requested <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true" title="class or interface in java.nio.channels"><CODE>FileChannel.MapMode</CODE></A>. 1191 1192 <p>Files are mapped from offset 0 to <code>size</code>. 1193 1194 <p>If the mode is <A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.MapMode.html?is-external=true#READ_WRITE" title="class or interface in java.nio.channels"><CODE>FileChannel.MapMode.READ_WRITE</CODE></A> and the file does not exist, 1195 it will be created with the requested <code>size</code>. Thus this method is 1196 useful for creating memory mapped files which do not yet exist. 1197 1198 <p>This only works for files <= <A HREF="http://java.sun.com/javase/6/docs/api/java/lang/Integer.html?is-external=true#MAX_VALUE" title="class or interface in java.lang"><CODE>Integer.MAX_VALUE</CODE></A> bytes. 1199 <P> 1200 <DD><DL> 1201 <DT><B>Parameters:</B><DD><CODE>file</CODE> - the file to map<DD><CODE>mode</CODE> - the mode to use when mapping <code>file</code> 1202 <DT><B>Returns:</B><DD>a buffer reflecting <code>file</code> 1203 <DT><B>Throws:</B> 1204 <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 1205 <DD><CODE><A HREF="http://java.sun.com/javase/6/docs/api/java/io/FileNotFoundException.html?is-external=true" title="class or interface in java.io">FileNotFoundException</A></CODE><DT><B>Since:</B></DT> 1206 <DD>2010.01.04 <b>tentative</b></DD> 1207 <DT><B>See Also:</B><DD><A HREF="http://java.sun.com/javase/6/docs/api/java/nio/channels/FileChannel.html?is-external=true#map(java.nio.channels.FileChannel.MapMode, long, long)" title="class or interface in java.nio.channels"><CODE>FileChannel.map(MapMode, long, long)</CODE></A></DL> 1208 </DD> 1209 </DL> 1210 <!-- ========= END OF CLASS DATA ========= --> 1211 <HR> 1212 1213 1214 <!-- ======= START OF BOTTOM NAVBAR ====== --> 1215 <A NAME="navbar_bottom"><!-- --></A> 1216 <A HREF="#skip-navbar_bottom" title="Skip navigation links"></A> 1217 <TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY=""> 1218 <TR> 1219 <TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> 1220 <A NAME="navbar_bottom_firstrow"><!-- --></A> 1221 <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY=""> 1222 <TR ALIGN="center" VALIGN="top"> 1223 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD> 1224 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD> 1225 <TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD> 1226 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="class-use/Files.html"><FONT CLASS="NavBarFont1"><B>Use</B></FONT></A> </TD> 1227 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD> 1228 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD> 1229 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD> 1230 <TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD> 1231 </TR> 1232 </TABLE> 1233 </TD> 1234 <TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM> 1235 </EM> 1236 </TD> 1237 </TR> 1238 1239 <TR> 1240 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 1241 <A HREF="../../../../com/google/common/io/FileBackedOutputStream.html" title="class in com.google.common.io"><B>PREV CLASS</B></A> 1242 <A HREF="../../../../com/google/common/io/Flushables.html" title="class in com.google.common.io"><B>NEXT CLASS</B></A></FONT></TD> 1243 <TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2"> 1244 <A HREF="../../../../index.html?com/google/common/io/Files.html" target="_top"><B>FRAMES</B></A> 1245 <A HREF="Files.html" target="_top"><B>NO FRAMES</B></A> 1246 <SCRIPT type="text/javascript"> 1247 <!-- 1248 if(window==top) { 1249 document.writeln('<A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A>'); 1250 } 1251 //--> 1252 </SCRIPT> 1253 <NOSCRIPT> 1254 <A HREF="../../../../allclasses-noframe.html"><B>All Classes</B></A> 1255 </NOSCRIPT> 1256 1257 1258 </FONT></TD> 1259 </TR> 1260 <TR> 1261 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 1262 SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD> 1263 <TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2"> 1264 DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD> 1265 </TR> 1266 </TABLE> 1267 <A NAME="skip-navbar_bottom"></A> 1268 <!-- ======== END OF BOTTOM NAVBAR ======= --> 1269 1270 <HR> 1271 1272 </BODY> 1273 </HTML> 1274