?? readserverme.java
字號:
//import java.applet.*;
import java.awt.*;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.net.*;
import java.io.*;
public class ReadServerMe extends Frame{
private TextArea contents;
private String site;
public ReadServerMe(String s)
{
contents = new TextArea("Please wait ...", 100,140);
add (contents);
site = new String(s);
}
public void run()
{
URL fileURL = null;
InputStream input;
BufferedReader dataInput;
String text;
FileOutputStream fout;//
try{
fileURL = new URL(site);//"http://www.bupt.edu.cn");//"http://www.deitel.com/test/test.txt");
}
catch (MalformedURLException e){
System.err.println("Exception: " + e.toString());
}
try{
input = fileURL.openStream();
dataInput = new BufferedReader (new InputStreamReader(input));
contents.setText("The file contents are:\n");
fout = new FileOutputStream("fout.txt");//
while((text = dataInput.readLine()) != null){
text += "\n";
contents.append(text);
//char buf[] = new char[text.length()];
//text.getChars(0, text.length(), buf, 0);
byte buf[] = text.getBytes();
for(int i = 0; i < buf.length; i++)
fout.write(buf[i]);
}
fout.close();
dataInput.close();
}
catch(IOException e){
System.err.println("Exception: " + e.toString());
}
catch(Exception e){
System.err.println("Exception: " + e.toString());
}
}
public static void main(String args[])
{
ReadServerMe r = new ReadServerMe("http://www.bupt.edu.cn");
r.run();
r.setSize(600,400);
r.setVisible(true);
//r.addWindowListener(new QuitWindow(this));
r.addWindowListener(new WindowListener(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
public void windowOpened(WindowEvent e){};
public void windowClosed(WindowEvent e){};
public void windowIconified(WindowEvent e){};
public void windowDeiconified(WindowEvent e){};
public void windowActivated(WindowEvent e){};
public void windowDeactivated(WindowEvent e){};
});
}
}
/*
class QuitWindow implements WindowListener
{
private ReadServerMe rsm;
public QuitWindow(ReadServerMe rsm)
{
this.rsm = rsm;
}
public void windowClosing(WindowEvent e){
rsm.dispose();
//System.exit(0);
}
public void windowOpened(WindowEvent e){};
public void windowClosed(WindowEvent e){};
public void windowIconified(WindowEvent e){};
public void windowDeiconified(WindowEvent e){};
public void windowActivated(WindowEvent e){};
public void windowDeactivated(WindowEvent e){};
}*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -