哈哈,我是菜鸟一只。我正好编过一个程序,把服务器上没有数字签名、与.class在
同一个目录下的文件一把头读到 Applet 的函数,希望对你有帮助:    public int DownLoadRemoteFile()
    {
        URL              fileURL;
        InputStream      input;
        DataInputStream  fd;
        String           x;
        int              i,y,Length;
        byte             FileBuffer[];        x=getDocumentBase().toString(); // 构造数据文件完整的 URL
        y=x.lastIndexOf("/");
        x=x.substring(0,y+1);        try // 打开数据文件
        {
             fileURL=new URL(x+"/"+getParameter("FILENAME"));
        }
        catch (MalformedURLException e)
        {
             fileURL=null;
        }        try // 打开下载输入流
        {
             input=fileURL.openStream();
        }
        catch (IOException e)
        {
             input=null;
        }        fd=new DataInputStream(input); // 打开数据流
        FileBuffer=new byte[90480]; // 为文件开辟存储空间,已经文件大小是 90480
        try
        {
            fd.readFully(CardDot); // 把文件读进来
        }
        catch(IOException e)
        {
        }        try // 关闭数据流
        {
             fd.close();
        }
        catch(IOException e)
        {
             fd=null;
        }
        try
        {
            input.close();
        }
        catch(IOException e)
        {
            input=null;
        }        return 0;
    }
不过, 要在 .htm 文件里加入:
<param name=FILENAME value="你的数据文件名">

解决方案 »

  1.   

    对不起,写错了,把  fd.readFully(CardDot); // 把文件读进来改成 fd.readFully(FileBuffer); // 把文件读进来
    Sorry Sorry
            
            
      

  2.   

    getDocumentBase()
    这个函数我也用了,但是老是报告未定义。使用这个函数要import哪个类呀???
      

  3.   

    哈哈,菜鸟我又来了。我包含的包是:
    import java.awt.*;
    import java.applet.*;
    import java.io.*;
    import java.net.*;
    import java.awt.event.*;
    我用的是 VJ++6.0