各位大哥大姐,小弟我又遇到问题了。我用的是JSDK
在书上扒下来的程序清单怎么也能出错?
还要请各位帮下忙!
程序清单testDigest
import java.io.*;
import java.security.*;
public class testDigest{
/**----------------------------------------
*<br>功能概述:测试摘要流
-----------------------------------------*/
public void testOperate(){
try{
MessageDigest sha = MessageDigest.getInstance("SHA");
DigestOutputStream dos = new DigestOutputStream(System.out,sha);
byte buffer[] = new byte[128];
while(true){
int byteRead = System.in.read(buffer);
if(byteRead<0) break;
dos.write(buffer,0,byteRead);
}
dos.flush();
dos.close();
}
catch(IOException e){}
}//testoperate()
public static void main(String args[]){
testDigest td = new testDigest();
td.testOperate();
}//main()
}/**testDigest*/
不能生成.class文件 错误是
testDigest.java:10: unreported exception java.security.NoSuchAlgorithmException;
must be caught or declared to be thrown
MessageDigest sha = MessageDigest.getInstance("SHA");
^
程序清单testWindowListener
import javax.swing.*;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;
public class testWindowListener extends JFrame implements WindowListener{
public testWindowListener(){
super("testWindowListener");
setSize(300,100);
this.addWindowListener(this);
}//testWindowListener()
public void log(String strInfo){
System.out.println(strInfo);
}//log()
/**---------------------------------------------
*<br>功能概述:实现窗口事件接口中的方法
----------------------------------------------*/
public void windowActivated(WindowEvent e){
log("窗口被激活...");
}//windowActivated()
public void windowClosed(WindowEvent e){
log("窗口关闭之后...");
}//windowClosed()
public void windowClosing(WindowEvent e){
log("关闭过程中...");
}//windowClosing()
public void windowDeactivated(WindowEvent e){
log("窗口不在处于激活状态时...");
}//windowDeactivated()
public void windowDeiconifieded(WindowEvent e){
log("窗口大小从最小到正常时...");
}//windowDeiconifieded()
public void windowIconified(WindowEvent e){
log("窗口大小从正常到最小时...");
}//windowIconified()
public void windowOpened(WindowEvent e){
log("窗口第一次被打开时...");
}//windowOpened()
public static void main(String args[]){
testWindowListener twl = new testWindowListener();
twl.show();
}//main()
}/**testWindowListener*/
不能生成.class文件 错误是
testWindowListener is not abstract and does not override abstract method
windowDeiconified(java.awt.event.WindowEvent) in java.awt.event.WindowListener
好象不是因为打错字,我检查好几遍了。谁能帮我看一下,我脑袋都大了!
[此贴子已经被作者于2005-12-27 19:54:36编辑过]