public class Applet1 extends Applet
{
public void getUrl() throws IOException
{
URL url = new URL("http://www.google.com/");
InputStream in = url.openStream();
InputStreamReader ll = new InputStreamReader(in);
BufferedReader bufReader = new BufferedReader(ll);
PageText.setText(bufReader.toString());
}
TextArea ls = new TextArea(); public void init()
{
this.setLayout(new BorderLayout());
this.add("",PageText);
}
}我是在网页上用script调用这个公共函数getUrl.

解决方案 »

  1.   

    applet不能访问其他的host,除自己所在(来自)的外
      

  2.   

    不好意思,把一行贴错了。
    TextArea ls = new TextArea();
    应为
    TextArea PageText = new TextArea(300,300);
      

  3.   

    to bdsc():那么applet岂不是不能从webserver上得到文件了吗?
      

  4.   

    to bdsc():不是不能,而是只能从它来的那个网站得到文件是吗?
    如果是,那在调试时岂不是不好办?
      

  5.   

    请检查JAVA环境是否设置了代理服务器什么的,可以到控制面板的JAVA小程序图标进入看看
      

  6.   

    to  liusoft(凤梨罐头):我用的是VCJ++6,环境我只是设了一个Project Properties...的ClassPath,其它就全是默认了。我的操作系统是win98,控制面板里找不到JAVA小程序图标。