-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReadFileFromDirectory.java
More file actions
33 lines (29 loc) · 941 Bytes
/
ReadFileFromDirectory.java
File metadata and controls
33 lines (29 loc) · 941 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
30
31
32
33
//Read a file from a directory and write it in to another file
import java.io.FileInputStream;
import java.io.FileOutputStream;
/**
* Created with IntelliJ IDEA.
* User: sujit
* Date: 7/26/13
* Time: 11:29 PM
* To change this template use File | Settings | File Templates.
*/
public class ReadFileFromDirectory {
public static void main(String ar[]){
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
try {
fileInputStream = new FileInputStream("d:\\readmyfile.txt");
fileOutputStream = new FileOutputStream("d:\\writemyfile.txt");
int readLine ;
while(( readLine=fileInputStream.read())!=-1){
fileOutputStream.write(readLine);
}
fileInputStream.close();
fileOutputStream.close();
}
catch (Exception e){
System.out.print(e);
}
}
}