📄 monitorupdate.java
字号:
import javax.swing.*;
import java.awt.*;
import java.io.*;
public class MonitorUpdate extends JFrame implements Runnable
{
BufferedReader br;
String content;
public MonitorUpdate() throws Exception
{
br=new BufferedReader(new FileReader("1.txt"));
String tmp=null;
while((tmp=br.readLine())!=null)
content=content+tmp;
br.close();
this.setBounds(100,100,200,100);
this.setVisible(true);
new Thread(this).start();
}
public void run()
{
while(true)
{
try
{
br=new BufferedReader(new FileReader("1.txt"));
String tmp=null;
String r=null;
while((tmp=br.readLine())!=null)
r=r+tmp;
br.close();
if(!content.equals(r))
JOptionPane.showMessageDialog(this,"File is updated!");
Thread.sleep(5000);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
public static void main(String [] args) throws Exception
{
new MonitorUpdate ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -