Package org.apache.bookkeeper.util
Class IOUtils
- java.lang.Object
-
- org.apache.bookkeeper.util.IOUtils
-
public class IOUtils extends java.lang.ObjectAn utility class for I/O related functionality.
-
-
Constructor Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidclose(org.slf4j.Logger log, java.io.Closeable closeable)Close the Closeable object and ignore anyIOExceptionor null pointers.static voidclose(org.slf4j.Logger log, java.io.Closeable... closeables)Close the Closeable objects and ignore anyIOExceptionor null pointers.static booleanconfirmPrompt(java.lang.String prompt)Confirm prompt for the console operations.static java.io.FilecreateTempDir(java.lang.String prefix, java.lang.String suffix)Create a temp directory with given prefix and suffix.static java.io.FilecreateTempDir(java.lang.String prefix, java.lang.String suffix, java.io.File dir)Create a temp directory with given prefix and suffix in the specified dir.static java.io.FilecreateTempFileAndDeleteOnExit(java.lang.String prefix, java.lang.String suffix)Create a temp directory with given prefix and suffix.static voidwriteFully(java.nio.channels.WritableByteChannel bc, java.nio.ByteBuffer buf)Write a ByteBuffer to a WritableByteChannel, handling short writes.
-
-
-
Method Detail
-
close
public static void close(org.slf4j.Logger log, java.io.Closeable... closeables)Close the Closeable objects and ignore anyIOExceptionor null pointers. Must only be used for cleanup in exception handlers.- Parameters:
log- the log to record problems to at debug level. Can be null.closeables- the objects to close
-
close
public static void close(org.slf4j.Logger log, java.io.Closeable closeable)Close the Closeable object and ignore anyIOExceptionor null pointers. Must only be used for cleanup in exception handlers.- Parameters:
log- the log to record problems to at debug level. Can be null.closeable- the objects to close
-
confirmPrompt
public static boolean confirmPrompt(java.lang.String prompt) throws java.io.IOExceptionConfirm prompt for the console operations.- Parameters:
prompt- Prompt message to be displayed on console- Returns:
- Returns true if confirmed as 'Y', returns false if confirmed as 'N'
- Throws:
java.io.IOException
-
writeFully
public static void writeFully(java.nio.channels.WritableByteChannel bc, java.nio.ByteBuffer buf) throws java.io.IOExceptionWrite a ByteBuffer to a WritableByteChannel, handling short writes.- Parameters:
bc- The WritableByteChannel to write tobuf- The input buffer- Throws:
java.io.IOException- On I/O error
-
createTempDir
public static java.io.File createTempDir(java.lang.String prefix, java.lang.String suffix) throws java.io.IOExceptionCreate a temp directory with given prefix and suffix.- Parameters:
prefix- prefix of the directory namesuffix- suffix of the directory name- Returns:
- directory created
- Throws:
java.io.IOException
-
createTempDir
public static java.io.File createTempDir(java.lang.String prefix, java.lang.String suffix, java.io.File dir) throws java.io.IOExceptionCreate a temp directory with given prefix and suffix in the specified dir.- Parameters:
prefix- prefix of the directory namesuffix- suffix of the directory namedir- The directory in which the file is to be created, or null if the default temporary-file directory is to be used- Returns:
- directory created
- Throws:
java.io.IOException
-
createTempFileAndDeleteOnExit
public static java.io.File createTempFileAndDeleteOnExit(java.lang.String prefix, java.lang.String suffix) throws java.io.IOExceptionCreate a temp directory with given prefix and suffix.- Parameters:
prefix- prefix of the directory namesuffix- suffix of the directory name- Returns:
- directory created
- Throws:
java.io.IOException
-
-