-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestThread.java
More file actions
72 lines (56 loc) · 1.63 KB
/
TestThread.java
File metadata and controls
72 lines (56 loc) · 1.63 KB
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
72
package bounceThread;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
public class TestThread {
public static void main(String[] args) {
// TODO Auto-generated method stub
//TestRunnable tR=null;
//Thread t=null;
for(int i=0;i<1;i++){
// TestRunnable tR=new TestRunnable(i);
// Thread t=new Thread(tR);
// t.start();
int m=0;
// System.out.println("HAHAHAHAHAH");
// int m=3;
String encoding="GBK";
System.out.println("ADFA");
try {
File f=new File("m.txt");
InputStreamReader read = new InputStreamReader(
new FileInputStream(f),encoding);//考虑到编码格式
BufferedReader bufferedReader = new BufferedReader(read);
String lineTxt = null;
while((lineTxt = bufferedReader.readLine()) != null){
System.out.println(lineTxt);
}
System.out.println("HAHAHAHAHAH");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println("主线程完成");
}
}
class TestRunnable implements Runnable{
private int j;
public TestRunnable(int i){
this.j=i;
}
public void run(){
for(int i=1;i<1000;i++)
System.out.println("我是线程循环"+j);
}
}