Class IOUtils

java.lang.Object
org.apache.bookkeeper.util.IOUtils

public class IOUtils extends Object
An utility class for I/O related functionality.
  • Constructor Details

    • IOUtils

      public IOUtils()
  • Method Details

    • close

      public static void close(org.slf4j.Logger log, Closeable... closeables)
      Close the Closeable objects and ignore any IOException or 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, Closeable closeable)
      Close the Closeable object and ignore any IOException or 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(String prompt) throws IOException
      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

      public static void writeFully(WritableByteChannel bc, ByteBuffer buf) throws IOException
      Write a ByteBuffer to a WritableByteChannel, handling short writes.
      Parameters:
      bc - The WritableByteChannel to write to
      buf - The input buffer
      Throws:
      IOException - On I/O error
    • createTempDir

      public static File createTempDir(String prefix, String suffix) throws IOException
      Create a temp directory with given prefix and suffix.
      Parameters:
      prefix - prefix of the directory name
      suffix - suffix of the directory name
      Returns:
      directory created
      Throws:
      IOException
    • createTempDir

      public static File createTempDir(String prefix, String suffix, File dir) throws IOException
      Create a temp directory with given prefix and suffix in the specified dir.
      Parameters:
      prefix - prefix of the directory name
      suffix - suffix of the directory name
      dir - 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

      public static File createTempFileAndDeleteOnExit(String prefix, String suffix) throws IOException
      Create a temp directory with given prefix and suffix.
      Parameters:
      prefix - prefix of the directory name
      suffix - suffix of the directory name
      Returns:
      directory created
      Throws:
      IOException