-
Notifications
You must be signed in to change notification settings - Fork 0
/
threadfile.java
66 lines (57 loc) · 1.39 KB
/
threadfile.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
import java.io.*;
class child1 extends Thread
{
public void run() {
try {
FileInputStream fin = new FileInputStream("f1.txt");
FileOutputStream fout = new FileOutputStream("f2.txt");
int i = fin.read();
while (i != -1) {
char c = (char) i;
if (c >= 'a' && c <= 'z') {
fout.write(c);
}
i = fin.read();
}
fin.close();
fout.close();
} catch (FileNotFoundException fe) {
}
catch (IOException e)
{
}
}
}
class child2 extends Thread
{
public void run() {
try {
FileInputStream fin = new FileInputStream("f1.txt");
FileOutputStream fout1 = new FileOutputStream("f3.txt");
int n = fin.read();
while (n != -1) {
char ch = (char) n;
if (ch >= 'A' && ch <= 'Z') {
fout1.write(ch);
}
n = fin.read();
}
fin.close();
fout1.close();
} catch (FileNotFoundException fe) {
}
catch (IOException e)
{
}
}
}
class threadfile
{
public static void main(String a[])
{
child1 ch1=new child1();
ch1.start();
child2 ch2=new child2();
ch2.start();
}
}