A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
26
Task/File-IO/Java/file-io-3.java
Normal file
26
Task/File-IO/Java/file-io-3.java
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import java.io.*;
|
||||
import java.nio.channels.*;
|
||||
|
||||
public class FileIODemo3 {
|
||||
public static void main(String args[]) {
|
||||
try {
|
||||
final FileChannel in = new FileInputStream("input.txt").getChannel();
|
||||
try {
|
||||
final FileChannel out = new FileOutputStream("output.txt").getChannel();
|
||||
try {
|
||||
out.transferFrom(in, 0, in.size());
|
||||
}
|
||||
finally {
|
||||
out.close();
|
||||
}
|
||||
}
|
||||
finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
System.err.println("Exception while trying to copy: "+e);
|
||||
e.printStackTrace(); // stack trace of place where it happened
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue