forked from codehouseindia/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCopy file.py
More file actions
29 lines (24 loc) · 756 Bytes
/
Copy file.py
File metadata and controls
29 lines (24 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# https://www.facebook.com/100025945953774/posts/695502641324595/?app=fbl
# subscribed by code house
import java.io.FileInputStream;
import java.io.FileOutputStream;
class Main {
public static void main(String[] args) {
byte[] array = new byte[50];
try {
FileInputStream sourceFile = new FileInputStream("input.txt");
FileOutputStream destFile = new FileOutputStream("newFile");
// reads all data from input.txt
sourceFile.read(array);
// writes all data to newFile
destFile.write(array);
System.out.println("The input.txt file is copied to newFile.");
// closes the stream
sourceFile.close();
destFile.close();
}
catch (Exception e) {
e.getStackTrace();
}
}
}