Package org.apache.pinot.common.utils
Class FileUtils
- java.lang.Object
-
- org.apache.pinot.common.utils.FileUtils
-
public class FileUtils extends Object
-
-
Method Summary
Modifier and Type Method Description static voidclose(Closeable... closeables)Another version ofclose(Iterable)which allows to pass variable number of closeable resources when the caller doesn't already have them in a collection.static voidclose(Iterable<? extends Closeable> closeables)static voidmoveFileWithOverwrite(File srcFile, File destFile)Deletes the destination file if it exists then calls org.apache.commons moveFile.static voidtransferBytes(FileChannel src, long position, long count, FileChannel dest)Transfers bytes from the source file to the destination file.
-
-
-
Method Detail
-
moveFileWithOverwrite
public static void moveFileWithOverwrite(File srcFile, File destFile) throws IOException
Deletes the destination file if it exists then calls org.apache.commons moveFile.- Parameters:
srcFile-destFile-- Throws:
IOException
-
transferBytes
public static void transferBytes(FileChannel src, long position, long count, FileChannel dest) throws IOException
Transfers bytes from the source file to the destination file. This method can handle transfer size larger than 2G.- Parameters:
src- Source file channelposition- Position in source filecount- Number of bytes to transferdest- Destination file channel- Throws:
IOException
-
close
public static void close(Iterable<? extends Closeable> closeables) throws IOException
Close a collection ofCloseableresources This is a utility method to help release multipleCloseableresources in a safe manner without leaking. As an example if we have a list of Closeable resources, then the following code is prone to leaking 1 or more subsequent resources if an exception is thrown while closing one of them. for (closeable_resource : resources) { closeable_resource.close() } The helper methods provided here do this safely while keeping track of exception(s) raised during close() of each resource and still continuing to close subsequent resources.- Parameters:
closeables- collection of resources to close- Throws:
IOException
-
close
public static void close(Closeable... closeables) throws IOException
Another version ofclose(Iterable)which allows to pass variable number of closeable resources when the caller doesn't already have them in a collection.- Parameters:
closeables- one or more resources to close- Throws:
IOException
-
-