Class IOUtils

java.lang.Object
org.esa.snap.core.util.io.IOUtils

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

    • IOUtils

      public IOUtils()
  • Method Details

    • copyBytes

      public static void copyBytes(InputStream is, OutputStream os) throws IOException
      Reads bytes from the given input stream and writes them to the given output stream until the end of the input stream is reached.
      Parameters:
      is - the input stream
      os - the output stream
      Throws:
      IOException - if an I/O error occurs
    • copyBytesAndClose

      public static void copyBytesAndClose(InputStream is, OutputStream os) throws IOException
      Calls copyBytes(java.io.InputStream, java.io.OutputStream) and safely closes both streams.
      Parameters:
      is - the input stream
      os - the output stream
      Throws:
      IOException - if an I/O error occurs
    • createDir

      public static boolean createDir(File dir) throws IOException
      Creates the specified directory. Does nothing if the directory already exists otherwise it is created. If creation fails, an I/O exception is thrown.
      Parameters:
      dir - the directory to be created
      Returns:
      true if it has been created, false if the directory already exists
      Throws:
      IOException - if the directory could not be created