应该可以实现把,但是filereader好象不行...

解决方案 »

  1.   

    是用net包的URL就行了阿,反正你肯定知道路径的
    URL urltmp = new URL(filepath);
    当然filepath要形如http://*******/t.txt之类
    后面的操作不用说了吧,咔咔,直接请求读取
      

  2.   

    copyright(笨蛋白痴神经质),给个写的例子,行吗
      

  3.   

    applet只能访问它被下载的服务器的东西。
      

  4.   

    就是要访问它被下载的服务器上的文件!!!
    我写了一些代码,但是出错,请帮忙看看:
    import java.awt.*;
    import java.awt.event.*;
    import java.applet.*;
    import java.io.*;
    import java.net.*;
    //import java.util.*;public class writedata extends Applet
    {
    public void init()
    {
    try{
       URL filedata=null;
       //DataOutputStream dos=null;
       filedata=new URL(getCodeBase()+"data.txt");
       URLConnection con=filedata.openConnection();
       PrintStream ps=new PrintStream(con.getOutputStream());
       ps.println("aaa");
       ps.close();
      }catch(Exception e){System.out.println(e.getMessage());}
    }
    }
    结果在html文件中浏览时,报错:protocol doesn't support output
    有高手能指点一下吗?
      

  5.   

    肯定可以写,但需要加策略文件!我没太研究!
    要想浏览服务器端的文件(TXT、HTML等)可以下面这样做!
    import java.applet.*;
    import java.awt.*;
    import java.net.*;
        public class BasicApplet extends Applet {
            
            public void init() {
                // Called once by the browser when it starts the applet
            }
            public void start() {
             try {
                URL url = new URL(this.getDocumentBase(),"2.txt");
                
                this.getAppletContext().showDocument(url,"_blank");
                         
            } catch (MalformedURLException e) {
                 //textField1.setText(e.toString());
            }        // Called whenever the page containing this applet is made visible
            }
            public void stop() {
                // Called whenever the page containing this applet is not visible
            }
            public void destroy() {
                // Called once when the browser destroys this applet
            }
            public void paint(Graphics g) {
                // Called whenever this applet needs to repaint itself
            }
        }
      

  6.   

    2.txt和你的CLASS文件在同一目录下!