package study;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Demo4 extends JFrame {
JLabel l1;
public Demo4() {
setBounds(1000, 100, 800, 100);
Font f = new Font("隶书", Font.BOLD+Font.ITALIC, 40);
JPanel p1 = new JPanel();
l1= new JLabel("噩梦开始");
l1.setFont(f);
p1.add(l1);
add(p1);
setVisible(true);
}
public static void main(String[] args) throws Exception {
Demo4 d = new Demo4();
File f = new File("src/CollegeGrade4.txt");
FileInputStream fr = new FileInputStream(f);
BufferedReader br = new BufferedReader(new InputStreamReader(fr));
String str = br.readLine();
while(str!=null) {
Thread.sleep(1000);
int x = str.indexOf("#");
int y = str.indexOf("#", x+1);
String s = str.substring(0, x);
s = s + str.substring(x+1,y);
d.l1.setText(s);
str=br.readLine();
}
}
}
文件内容为四级单词,之间有#隔开