文件防到服务器内,
客户端通过http联接可以直接获取到文件流。

解决方案 »

  1.   

    //用servlet发送图片的例子
    import java.util.*;
    import java.text.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.net.*;public class ShowImage extends HttpServlet
     {
          public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException{
            this.doPost(req,res);
        }//doGet    public void doPost(HttpServletRequest req, HttpServletResponse res)throws ServletException,IOException{
                res.setContentType("images/");
                String fileName = req.getParameter("IMAGEURL") ;
                if(fileName==null){
                    return;
                }
                File file = new File("d:/aa.gif");
                if(!file.exists()){
                    return;
                }
                FileInputStream  is = new FileInputStream(file);
                OutputStream out = res.getOutputStream();
                byte[] buffer = new byte[1024];
                int size = -1;
                while((size = is.read(buffer))!=-1){
                    out.write(buffer,0,size);
                }//while
                out.flush();
                out.close();
                is.close();
            
        }//doPost