Rev 15 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
30 | daniel-mar | 1 | package de.viathinksoft.immortal.genX; |
15 | daniel-mar | 2 | |
3 | import java.io.*; |
||
4 | import java.nio.channels.*; |
||
5 | |||
6 | /** |
||
7 | * |
||
8 | * @see http://www.rgagnon.com/javadetails/java-0064.html |
||
9 | * |
||
10 | */ |
||
11 | public class FileUtils { |
||
12 | public static void copyFile(File in, File out) throws IOException { |
||
13 | FileChannel inChannel = new FileInputStream(in).getChannel(); |
||
14 | FileChannel outChannel = new FileOutputStream(out).getChannel(); |
||
15 | try { |
||
16 | inChannel.transferTo(0, inChannel.size(), outChannel); |
||
17 | } catch (IOException e) { |
||
18 | throw e; |
||
19 | } finally { |
||
20 | if (inChannel != null) |
||
21 | inChannel.close(); |
||
22 | if (outChannel != null) |
||
23 | outChannel.close(); |
||
24 | } |
||
25 | } |
||
26 | |||
27 | public static void main(String args[]) throws IOException { |
||
28 | FileUtils.copyFile(new File(args[0]), new File(args[1])); |
||
29 | } |
||
30 | } |