如题,最好有例子或源码,出结果就结帖!
谢谢各位!!

解决方案 »

  1.   

    ??????
    打开客户端的文件?不行的。或着用Applet+授权
    服务器端的就是普通文件操作了
      

  2.   

    我做的是一个浏览器
    想打开本地的文件
    因为我不知道怎么打开其他服务器的文件,我不会配
    这是一个例子
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    class Win extends JFrame 
    implements ActionListener,Runnable
    {  
       JButton button;
       URL url;
       JTextField text;
       JEditorPane editPane; 
       byte b[]=new byte[118];
       Thread thread;
       public Win()
       {  
          text=new JTextField(20);
          editPane=new JEditorPane();
          editPane.setEditable(false);
          button=new JButton("确定");
          button.addActionListener(this);
          thread=new Thread(this);
          JPanel p=new JPanel();
          p.add(new JLabel("输入网址:"));
          p.add(text); 
          p.add(button);
          Container con=getContentPane();
          con.add(new JScrollPane(editPane),BorderLayout.CENTER);
          con.add(p,BorderLayout.NORTH);
          setBounds(60,60,360,300);
          setVisible(true);
          validate();
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       }
       public void actionPerformed(ActionEvent e)
       { 
          if(!(thread.isAlive())) 
             thread=new Thread(this);
          try{
               thread.start();
             }
          catch(Exception ee)
             {
                text.setText("我正在读取"+url);
             }
       }
      public void run()
       {
           try {    
                     int n=-1;
                     editPane.setText(null);
                     url=new URL(text.getText().trim());
                     editPane.setPage(url);
                }
              catch(MalformedURLException e1)
               {  
                     text.setText(""+e1);
                     return;
               }
              catch(IOException e1)
               {  
                     text.setText(""+e1);
                     return;
               }  
       }
    }
    public class Example

        public static void main(String args[])
        { 
           new Win();
        }
    }
      

  3.   

    完了,又废了50分
    我自己会了,只要把File类型的变量file变成URL型的就可以了,用的方法是file.toURL();
    然后再用JEditPane显示就可以了。
    现在全当散分了,我高兴了就结贴。
      

  4.   

    JEditPane直接指定url就可以显示了如果想用浏览器访问只要
    Runtime.getRuntime("iExplorer C:\\xxx.htm");