Skip to content

Commit c20dc79

Browse files
author
Dion Gillard
committed
Added fileCopy method
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/io/trunk@140298 13f79535-47bb-0310-9956-ffa450edef68
1 parent ff3752e commit c20dc79

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

src/java/org/apache/commons/io/FileUtils.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
* @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
7474
* @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
7575
* @author <a href="mailto:Christoph.Reck@dlr.de">Christoph.Reck</a>
76-
* @version $Id: FileUtils.java,v 1.6 2002/06/12 19:50:40 dlr Exp $
76+
* @version $Id: FileUtils.java,v 1.7 2002/06/22 06:52:40 dion Exp $
7777
*/
7878
public class FileUtils {
7979

@@ -221,6 +221,22 @@ public static void fileWrite(String fileName, String data) throws Exception {
221221
out.write(data.getBytes());
222222
out.close();
223223
}
224+
225+
/**
226+
* Copy a file. The new file will be created if it does not exist. This is
227+
* an inefficient method, which just calls {@link #fileRead(String)} and
228+
* then {@link #fileWrite(String,String)}
229+
*
230+
* @param inFileName the file to copy
231+
* @param outFileName the file to copy to
232+
* @throws Exception if fileRead or fileWrite throw it
233+
*/
234+
public static void fileCopy(String inFileName, String outFileName) throws
235+
Exception
236+
{
237+
String content = FileUtils.fileRead(inFileName);
238+
FileUtils.fileWrite(outFileName, content);
239+
}
224240

225241
/**
226242
* Deletes a file.

0 commit comments

Comments
 (0)