Package org.apache.bookkeeper.util
Class IOUtils
java.lang.Object
org.apache.bookkeeper.util.IOUtils
An utility class for I/O related functionality.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidClose the Closeable object and ignore anyIOExceptionor null pointers.static voidClose the Closeable objects and ignore anyIOExceptionor null pointers.static booleanconfirmPrompt(String prompt) Confirm prompt for the console operations.static FilecreateTempDir(String prefix, String suffix) Create a temp directory with given prefix and suffix.static FilecreateTempDir(String prefix, String suffix, File dir) Create a temp directory with given prefix and suffix in the specified dir.static FilecreateTempFileAndDeleteOnExit(String prefix, String suffix) Create a temp directory with given prefix and suffix.static voidwriteFully(WritableByteChannel bc, ByteBuffer buf) Write a ByteBuffer to a WritableByteChannel, handling short writes.
-
Constructor Details
-
IOUtils
public IOUtils()
-
-
Method Details
-
close
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
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
Confirm 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:
IOException
-
writeFully
Write a ByteBuffer to a WritableByteChannel, handling short writes.- Parameters:
bc- The WritableByteChannel to write tobuf- The input buffer- Throws:
IOException- On I/O error
-
createTempDir
Create a temp directory with given prefix and suffix.- Parameters:
prefix- prefix of the directory namesuffix- suffix of the directory name- Returns:
- directory created
- Throws:
IOException
-
createTempDir
Create 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:
IOException
-
createTempFileAndDeleteOnExit
Create a temp directory with given prefix and suffix.- Parameters:
prefix- prefix of the directory namesuffix- suffix of the directory name- Returns:
- directory created
- Throws:
IOException
-