JAVA怎样把图片从A   tomcat上传B   tomcat; 在同一个局域网内;求高手指导

解决方案 »

  1.   

    HttpClient
    http://blog.sina.com.cn/s/blog_978a39e4010120fg.html
      

  2.   

    tomcat?lz为什么要强调tomcat
    两台机子的话socket就好
      

  3.   

    用socket 通信,可以实现。
      

  4.   

    package com.test;import java.io.File;
    import java.io.FileOutputStream;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.net.URL;/**
     * 把其他服务器的文件保存到自己的服务器
     */
    public class GetServerFile {
    public static void main(String[] args) {
    try {
    InputStream input = null;
    OutputStream output = null;
    try {
    URL url = new URL("http://static11.photo.sina.com.cn/middle/60ce3cc9xvb1bhob1h3ay&690");
    input = url.openStream();
    output = new FileOutputStream(new File("D:\\opt\\j10.jpg"));
    byte[] buffer = new byte[1024];
    int i = 0;
    while ((i = input.read(buffer)) != -1) {
    output.write(buffer, 0, i);
    }
    } catch (Exception e) {
    e.printStackTrace();
    } finally {
    input.close();
    output.close();
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }
      

  5.   

    ftp上传;最简单的方式是共享,但是不安全
      

  6.   

    我现在采用;FTP上传;http访问;用ftp服务器+apache