-
Notifications
You must be signed in to change notification settings - Fork 0
/
clas.java
44 lines (39 loc) · 1 KB
/
clas.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
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import javax.swing.*;
class clas
{
private static BufferedReader br;
public static void main(String[] args)
{
JFrame f = new JFrame();
f.setSize(500, 500);
JTextArea t = new JTextArea();
f.add(t);
JFileChooser c = new JFileChooser();
int r = c.showOpenDialog(null);
File fi = null;
if( r == JFileChooser.APPROVE_OPTION)
{
fi = new File(c.getSelectedFile().getAbsolutePath());
}
try {
// String
String s1 = "", sl = "";
// File reader
FileReader fr = new FileReader(fi);
br = new BufferedReader(fr);
sl = br.readLine();
while ((s1 = br.readLine()) != null) {
sl = sl + "\n" + s1;
}
t.setText(sl);
}
catch (Exception evt) {
JOptionPane.showMessageDialog(f, evt.getMessage());
}
//f.show();
f.setVisible(true);
}
}