-
Notifications
You must be signed in to change notification settings - Fork 0
/
oddevenfile.java
71 lines (57 loc) · 1.32 KB
/
oddevenfile.java
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import java.io.*;
class c1 extends Thread
{
public void run() {
try {
FileInputStream fin = new FileInputStream("finput.txt");
FileOutputStream fout = new FileOutputStream("foutput.txt");
int i = fin.read();
while (i != -1) {
if(i%2==0)
{
fout.write(i);
}
i = fin.read();
}
fin.close();
fout.close();
} catch (FileNotFoundException fe) {
}
catch (IOException e)
{
}
}
}
class c2 extends Thread
{
public void run() {
try {
FileInputStream fin = new FileInputStream("finput.txt");
FileOutputStream fout1 = new FileOutputStream("foutput1.txt");
int n = fin.read();
while (n != -1) {
if(n%2!=0)
{
fout1.write(n);
}
n = fin.read();
}
fin.close();
fout1.close();
} catch (FileNotFoundException fe) {
}
catch (IOException e)
{
}
}
}
class oddevenfile
{
public static void main(String a[])
{
c1 ch1=new c1();
ch1.start();
c2 ch2=new c2();
ch2.start();
}
}