<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    阿郎的技術(shù)搏客

    成長軌跡

    文件上傳程序

    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.PageContext;

    public class UploadFile
    {
    private ServletRequest request;
    private ServletResponse response;
    private ServletConfig config;
    ServletInputStream DATA;
    int FormSize;
    File f1;
    FileOutputStream os;
    DataInputStream is;
    String filename;
    byte[] b;
    byte t;
    boolean flag=false;
    public UploadFile()
    { }
    public void initialize(ServletConfig config,HttpServletRequest request,HttpServletResponse response) throws IOException
    {
    this.request=request;
    this.response=response;
    this.config=config;
    DATA = request.getInputStream();
    FormSize=request.getContentLength();
    }
    public void initialize(PageContext pageContext) throws IOException
    {
    request=pageContext.getRequest();
    response=pageContext.getResponse();
    config=pageContext.getServletConfig();
    DATA = request.getInputStream();
    FormSize=request.getContentLength();
    }
    public boolean setFilename(String s)
    {
    try
    {
    File f1=new File(s);
    os=new FileOutputStream(f1);
    }
    catch(IOException e)
    {return(false);}
    return(true);
    }
    public void getByte()
    {
    int i=0;
    try
    {
    is=new DataInputStream(DATA);
    b=new byte[FormSize];

    while (true)
    {
    try
    {
    t=is.readByte();
    b[i]=t;
    i++;
    }
    catch(EOFException e)
    { break;}
    }
    is.close();}
    catch(IOException e)
    {}
    }

    public boolean save()
    {
    int i=0,start1=0,start2=0;
    String temp="";
    if (!flag)
    {
    getByte();
    flag=true;
    }
    try
    {
    temp=new String(b,"ISO8859_1");
    }
    catch(UnsupportedEncodingException e)
    {return(false);}

    start1=temp.indexOf("image/");
    temp=temp.substring(start1);

    start1=temp.indexOf("\r\n\r\n");

    temp=temp.substring(start1+4);
    start2=temp.indexOf(";\r\n");
    if (start2!=-1)
    {
    temp=temp.substring(0,start2);
    }
    try
    {
    byte[] img=temp.getBytes("ISO8859_1");
    for (i=0;i<img.length;i++)
    { os.write(img[i]); }
    os.close();
    }
    catch(IOException e)
    {return(false);}

    return(true);

    }
    }

    posted on 2007-05-11 15:34 alone 閱讀(248) 評論(0)  編輯  收藏


    只有注冊用戶登錄后才能發(fā)表評論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 99精品视频免费在线观看| 午夜不卡AV免费| 88xx成人永久免费观看| 亚洲国产精品无码AAA片| 无码日韩人妻AV一区免费l| 亚洲国产av一区二区三区| 蜜芽亚洲av无码一区二区三区 | 亚洲AⅤ无码一区二区三区在线| 亚洲精品久久无码| 国产精品冒白浆免费视频| 亚洲日韩AV一区二区三区中文| 免费鲁丝片一级在线观看| 亚洲精华液一二三产区| 午夜国产大片免费观看| 一级午夜a毛片免费视频| 亚洲精品国产自在久久| 热久久这里是精品6免费观看| 亚洲精品卡2卡3卡4卡5卡区| 午夜精品免费在线观看| 亚洲精品国产福利片| 免费a级毛片高清视频不卡| 亚洲欧美日韩中文字幕一区二区三区| 日本人的色道www免费一区| 黄色一级毛片免费| 亚洲精品色午夜无码专区日韩| 99久久免费中文字幕精品| 久久乐国产综合亚洲精品| xvideos亚洲永久网址| 免费毛片在线看不用播放器 | 亚洲中文无码永久免| yy6080久久亚洲精品| 亚洲欧洲免费视频| 亚洲成a人片在线观看精品| 国产精品无码一区二区三区免费 | 亚洲AV无码国产一区二区三区| 亚洲美女高清一区二区三区| 99精品视频在线观看免费播放| 亚洲看片无码在线视频| 久久亚洲中文字幕精品一区| 一级毛片免费视频| 免费一级全黄少妇性色生活片 |