|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.mahout.common.IOUtils
public final class IOUtils
I/O-related utility methods that don't have a better home.
| Nested Class Summary | |
|---|---|
static class |
IOUtils.DeleteFileOnClose
for temporary files, a file may be considered as a Closeable too,
where file is wiped on close and thus the disk resource is released
('closed'). |
static class |
IOUtils.MultipleOutputsCloseableAdapter
MultipleOutputs to closeable adapter. |
| Method Summary | |
|---|---|
static void |
close(Collection<? extends Closeable> closeables)
make sure to close all sources, log all of the problems occurred, clear closeables (to prevent repeating close attempts), re-throw the
last one at the end. |
static void |
quietClose(Connection closeable)
|
static void |
quietClose(ResultSet closeable)
|
static void |
quietClose(ResultSet resultSet,
Statement statement,
Connection connection)
Closes a ResultSet, Statement and Connection (if not null) and logs (but does not
rethrow) any resulting SQLException. |
static void |
quietClose(Statement closeable)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static void quietClose(ResultSet closeable)
public static void quietClose(Statement closeable)
public static void quietClose(Connection closeable)
public static void quietClose(ResultSet resultSet,
Statement statement,
Connection connection)
ResultSet, Statement and Connection (if not null) and logs (but does not
rethrow) any resulting SQLException. This is useful for cleaning up after a database query.
resultSet - ResultSet to closestatement - Statement to closeconnection - Connection to close
public static void close(Collection<? extends Closeable> closeables)
throws IOException
closeables (to prevent repeating close attempts), re-throw the
last one at the end. Helps resource scope management (e.g. compositions of
Closeables objects)
Typical pattern:
LinkedListcloseables = new LinkedList (); try { InputStream stream1 = new FileInputStream(...); closeables.addFirst(stream1); ... InputStream streamN = new FileInputStream(...); closeables.addFirst(streamN); ... } finally { IOUtils.close(closeables); }
closeables - must be a modifiable collection of Closeables
IOException - the last exception (if any) of all closed resources
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||