Package org.esa.snap.core.util.io
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 Summary
Constructors Constructor Description IOUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcopyBytes(InputStream is, OutputStream os)Reads bytes from the given input stream and writes them to the given output stream until the end of the input stream is reached.static voidcopyBytesAndClose(InputStream is, OutputStream os)CallscopyBytes(java.io.InputStream, java.io.OutputStream)and safely closes both streams.static booleancreateDir(File dir)Creates the specified directory.
-
-
-
Method Detail
-
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 streamos- the output stream- Throws:
IOException- if an I/O error occurs
-
copyBytesAndClose
public static void copyBytesAndClose(InputStream is, OutputStream os) throws IOException
CallscopyBytes(java.io.InputStream, java.io.OutputStream)and safely closes both streams.- Parameters:
is- the input streamos- 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:
trueif it has been created,falseif the directory already exists- Throws:
IOException- if the directory could not be created
-
-