Java中利用散列表实现股票行情的查询(3) System.err.println("充填数据时出错: " + excpt);} catch(NoSUChElementException excpt) {System.err.println("无效的数据记录 " +"in file: " + excpt);}} stockInput.close();} catch(FileNotFoundException excpt) {System.err.println("不能发现文件: " + excpt);return false;} catch(IOException excpt) {System.err.println("I/O故障: " + excpt);return false;} return true;}protected String getQuote(String StockID){String info;// 从Hashtable得到数据info = (String)stockInfo.get(StockID);if (info != null)return info;elsereturn "股票代码错误!";}public void paint(GraphiCS g){g.drawString("股票代码"+quoteid+":" ,10,60);g.drawString("股票名称"+"前收"+"今开"+"最高"+"最低"+"收盘"+"交易量"+"交易金额", 10, 90);g.drawString(quotename, 10, 120);}public void actionPerformed(ActionEvent ev){String label = ev.getActionCommand();if (label.equals("查询")){quoteid = stockID.getText();if(quoteid != null)quotename = getQuote(quoteid);else quotename = "请输入股票代码!";repaint();}}}
d:\jdk1.2\bin\appletviewer StockQuote.html