forked from javaexampractical/EndTermPracticalBScIT
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFile.java
More file actions
25 lines (25 loc) · 760 Bytes
/
Copy pathFile.java
File metadata and controls
25 lines (25 loc) · 760 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
import java.io.*;
class File
{
public static void main(String[] args) throws IOException
{
PrintWriter pw = new PrintWriter("file3.txt");
BufferedReader br1= new BufferedReader(new FileReader("file1.txt"));
BufferedReader br2= new BufferedReader(new FileReader("file2.txt"));
String line=br1.readLine();
while (line != null)
{
pw.println(line);
pw.flush();
line=br1.readLine();
}
line=br2.readLine();
while(line != null)
{
pw.println(line);
pw.flush();
line=br.readLine();
}
System.out.println("Merged file1.txt and file2.txt into file3.txt");
}
}