[Japi-cvs] SF.net SVN: japi:[1328] libs/io/trunk/src/prj/net/sf/japi/io/IOUtils.java
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2009-05-23 15:34:44
|
Revision: 1328 http://japi.svn.sourceforge.net/japi/?rev=1328&view=rev Author: christianhujer Date: 2009-05-23 15:34:37 +0000 (Sat, 23 May 2009) Log Message: ----------- Add convenience copy method that copies files, not streams. Modified Paths: -------------- libs/io/trunk/src/prj/net/sf/japi/io/IOUtils.java Modified: libs/io/trunk/src/prj/net/sf/japi/io/IOUtils.java =================================================================== --- libs/io/trunk/src/prj/net/sf/japi/io/IOUtils.java 2009-05-23 14:42:28 UTC (rev 1327) +++ libs/io/trunk/src/prj/net/sf/japi/io/IOUtils.java 2009-05-23 15:34:37 UTC (rev 1328) @@ -18,6 +18,9 @@ package net.sf.japi.io; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; @@ -56,6 +59,27 @@ } } + /** Copies a file. + * + * @param fromFile File to copy. + * @param toFile File to be the copy. + * + * @throws IOException in case of I/O problems. + */ + public static void copy(@NotNull final File fromFile, @NotNull final File toFile) throws IOException { + final InputStream in = new FileInputStream(fromFile); + try { + final OutputStream out = new FileOutputStream(toFile); + try { + copy(in, out); + } finally { + out.close(); + } + } finally { + in.close(); + } + } + /** Returns an iterable for lines from the specified reader. * @param in Reader for which to return lines. * @return An iterable for the lines of the specified reader. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |