用这个
try{
String txt = "";
URL url = new URL("URL地址");
URLConnection urlc = url.openConnection();
urlc.connect;
InputStream is = urlc.getInputStream();
....
is.close();
}
catch(Exception e){
}

解决方案 »

  1.   

    applet里面不能用file、datainputstream之类的,除非你的applet用了数字签名。试试下面的
    URLConnection con = (new URL(url)).openConnection();
            try {
                con.setDoOutput(true);
                con.setUseCaches(false);
                con.setRequestProperty("Content-Type", "text/plain");
                System.out.println(con.getContentLength());
                System.out.println("Sending data... ...");
                if (con.getContentLength() > 0) {
                    int s;
                    byte[] buf = new byte[4096];
                    while ((s = con.getInputStream().read(buf)) != -1) {
                        。。
                    }
                }
                System.out.println("Scope ended.");
            }
            catch (Exception e) {
                e.printStackTrace();
            }
            finally {
                try {
                    fos.close();
                }
                catch (Exception e) {}
                try {
                    con.getInputStream().close();
                }
                catch (Exception e) {}
                try {
                    con.getOutputStream().close();
                }
                catch (Exception e) {}
            }