-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemomerge.java
More file actions
43 lines (42 loc) · 788 Bytes
/
Demomerge.java
File metadata and controls
43 lines (42 loc) · 788 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
34
35
36
37
38
39
40
41
42
43
package lab9;
import java.io.FileInputStream;
import java.io.FileOutputStream;
public class Demomerge
{
public static void main(String a[])
{
FileInputStream ob1=null;
FileInputStream ob2=null;
FileOutputStream obj=null;
try{
ob1= new FileInputStream("abc.txt");
ob2= new FileInputStream("xyz.txt");
obj=new FileOutputStream("final.txt");
byte[] buffer=new byte[1024];
int i;
while((i=ob1.read(buffer))!=-1)
{
obj.write(buffer,0,i);
}
while((i=ob2.read(buffer))!=-1)
{
obj.write(buffer,0,i);
}
}
catch(Exception e)
{
System.out.println("\nIOException");
}
finally{
try{
ob1.close();
ob2.close();
obj.close();
}
catch(Exception e)
{
System.out.println("\nIOException");
}
}
}
}