public class FileUtils extends Object
| Modifier and Type | Class and Description | 
|---|---|
| static class  | FileUtils.FileCopyResultKeeps results of a file copy, including children and total size of the resultant files. | 
| Modifier and Type | Field and Description | 
|---|---|
| static com.google.common.base.Predicate<Throwable> | IS_EXCEPTIONUseful for retry functionality that doesn't want to stop Throwables, but does want to retry on Exceptions | 
| Constructor and Description | 
|---|
| FileUtils() | 
| Modifier and Type | Method and Description | 
|---|---|
| static MappedByteBufferHandler | map(File file)Fully maps a file read-only in to memory as per
  FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long). | 
| static FileUtils.FileCopyResult | retryCopy(com.google.common.io.ByteSource byteSource,
         File outFile,
         com.google.common.base.Predicate<Throwable> shouldRetry,
         int maxAttempts)Copy input byte source to outFile. | 
public static final com.google.common.base.Predicate<Throwable> IS_EXCEPTION
public static FileUtils.FileCopyResult retryCopy(com.google.common.io.ByteSource byteSource, File outFile, com.google.common.base.Predicate<Throwable> shouldRetry, int maxAttempts)
byteSource - Supplier for an input stream that is to be copied. The resulting stream is closed each iterationoutFile - Where the file should be written to.shouldRetry - Predicate indicating if an error is recoverable and should be retried.maxAttempts - The maximum number of assumed recoverable attempts to try before completely failing.RuntimeException - wrapping the inner exception on failure.public static MappedByteBufferHandler map(File file) throws IOException
FileChannel.map(java.nio.channels.FileChannel.MapMode, long, long).
 Files are mapped from offset 0 to its length.
This only works for files <= Integer.MAX_VALUE bytes.
 
Similar to Files.map(File), but returns MappedByteBufferHandler, that makes it easier to unmap
 the buffer within try-with-resources pattern:
 
 try (MappedByteBufferHandler fileMappingHandler = FileUtils.map(file)) {
   ByteBuffer fileMapping = fileMappingHandler.get();
   // use mapped buffer
 }file - the file to mapMappedByteBufferHandler, wrapping a read-only buffer reflecting fileFileNotFoundException - if the file does not existIOException - if an I/O error occursFileChannel.map(FileChannel.MapMode, long, long)Copyright © 2011–2017. All rights reserved.