InputStream is1 = new FileInputStream(
"d://users//lishup//桌面//fdj.xls");
如何修改上面的代码,获得服务器为192.168.190.55的桌面上的文件fdj.xls
谢谢

解决方案 »

  1.   

    URL u=new URL("URL路径");
    InputStream is=u.openStream();
      

  2.   

    我对路径不是很懂,URL路径只的是?
    谢谢啊
      

  3.   


                            URL file=new URL("file","192.168.190.55",23,"d://users//lishup//桌面//fdj.xls");

    System.out.println(file.getProtocol());
    System.out.println(file.getPort());
    System.out.println(file.getHost());
    System.out.println(file.getPath());
        

    InputStream uis=file.openStream();

      

  4.   

    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLConnection;public class App { public static String getDocumentAt(URL url) {
    // 此方法兼容HTTP和FTP协议
    StringBuffer document = new StringBuffer(); try { URLConnection conn = url.openConnection();
    BufferedReader reader = new BufferedReader(new InputStreamReader(
    conn.getInputStream()));
    String line = null;
    while ((line = reader.readLine()) != null) {
    document.append(line + "n");
    }
    reader.close();
    } catch (IOException e) {
    }
    return document.toString();
    } public static void main(String[] args) {
    URL url;
    try {
    url = new URL("file", "localhost", 23, "d://");
    //url = new URL("file", "192.168.190.55", 23, "d://users//lishup//桌面//fdj.xls");
    System.out.println(getDocumentAt(url));
    } catch (MalformedURLException e) {
    e.printStackTrace();
    }
    }
    }
      

  5.   

    打开HTTP连接
    开输入流读文件
    关闭输入流
    关闭HTTP连接