Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
26
Task/File-input-output/Java/file-input-output-3.java
Normal file
26
Task/File-input-output/Java/file-input-output-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