Update all new Tasks
This commit is contained in:
parent
00a190b0a6
commit
91df62d461
5697 changed files with 93386 additions and 804 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