亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? smartupload.java

?? java上傳文件工具非常實用 java上傳文件工具非常實用
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi
// Source File Name:   SmartUpload.java

package com.westerasoft.util.jspsmart.upload;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;

// Referenced classes of package com.jspsmart.upload:
//            Files, Request, SmartUploadException, File

public class SmartUpload{

  public byte m_binArray[];

  protected HttpServletRequest m_request;

  protected HttpServletResponse m_response;

  protected ServletContext m_application;

  private int m_totalBytes;

  private int m_currentIndex;

  private int m_startData;

  private int m_endData;

  private String m_boundary;

  private long m_totalMaxFileSize;

  private long m_maxFileSize;

  private Vector m_deniedFilesList;

  private Vector m_allowedFilesList;

  private boolean m_denyPhysicalPath;

  private boolean m_forcePhysicalPath;

  private String m_contentDisposition;

  public static final int SAVE_AUTO=0;

  public static final int SAVE_VIRTUAL=1;

  public static final int SAVE_PHYSICAL=2;

  private Files m_files;

  private Request m_formRequest;

  public SmartUpload(){
    m_totalBytes=0;
    m_currentIndex=0;
    m_startData=0;
    m_endData=0;
    m_boundary=new String();
    m_totalMaxFileSize=0L;
    m_maxFileSize=0L;
    m_deniedFilesList=new Vector();
    m_allowedFilesList=new Vector();
    m_denyPhysicalPath=false;
    m_forcePhysicalPath=false;
    m_contentDisposition=new String();
    m_files=new Files();
    m_formRequest=new Request();
  }

  public final void init(ServletConfig config) throws ServletException{
    m_application=config.getServletContext();
  }

  public final void initialize(ServletConfig config,HttpServletRequest request,
      HttpServletResponse response) throws
      ServletException{
    m_application=config.getServletContext();
    m_request=request;
    m_response=response;
  }

  public void service(HttpServletRequest request,HttpServletResponse response) throws
      IOException,ServletException{
    m_request=request;
    m_response=response;
  }

  public final void initialize(PageContext pageContext) throws ServletException{
    m_application=pageContext.getServletContext();
    m_request=(HttpServletRequest)pageContext.getRequest();
    m_response=(HttpServletResponse)pageContext.getResponse();
  }

  public final void initialize(ServletContext application,HttpSession session,
      HttpServletRequest request,
      HttpServletResponse response,JspWriter out) throws
      ServletException{
    m_application=application;
    m_request=request;
    m_response=response;
  }

  public void upload() throws SmartUploadException,IOException,
      ServletException{
    int totalRead=0;
    int readBytes=0;
    long totalFileSize=0L;
    boolean found=false;
    String dataHeader=new String();
    String fieldName=new String();
    String fileName=new String();
    String fileExt=new String();
    String filePathName=new String();
    String contentType=new String();
    String contentDisp=new String();
    String typeMIME=new String();
    String subTypeMIME=new String();
    boolean isFile=false;
    m_totalBytes=m_request.getContentLength();
    if(m_totalMaxFileSize>0&&m_totalMaxFileSize<m_totalBytes){
      throw new SmartUploadException("上傳文件太大,請重新選擇! (1110).");
    }
    m_binArray=new byte[m_totalBytes];
    for(;totalRead<m_totalBytes;totalRead+=readBytes){
      try{
        m_request.getInputStream();
        readBytes=m_request.getInputStream().read(m_binArray,totalRead,
            m_totalBytes-totalRead);
      } catch(Exception e){
        throw new SmartUploadException("上傳文件失敗,請重試!");
      }
    }

    for(;!found&&m_currentIndex<m_totalBytes;m_currentIndex++){
      if(m_binArray[m_currentIndex]==13){
        found=true;
      } else{
        m_boundary=m_boundary+(char)m_binArray[m_currentIndex];

      }
    }
    if(m_currentIndex==1){
      return;
    }
    m_currentIndex++;
    do{
      if(m_currentIndex>=m_totalBytes){
        break;
      }
      dataHeader=getDataHeader();
      m_currentIndex=m_currentIndex+2;
      isFile=dataHeader.indexOf("filename")>0;
      fieldName=getDataFieldValue(dataHeader,"name");
      if(isFile){
        filePathName=getDataFieldValue(dataHeader,"filename");
        fileName=getFileName(filePathName);
        fileExt=getFileExt(fileName);
        contentType=getContentType(dataHeader);
        contentDisp=getContentDisp(dataHeader);
        typeMIME=getTypeMIME(contentType);
        subTypeMIME=getSubTypeMIME(contentType);
      }
      getDataSection();
      if(isFile&&fileName.length()>0){
        fileExt=fileExt.toLowerCase();
        if(m_deniedFilesList.contains(fileExt)){
          throw new SmartUploadException(
              "上傳文件失敗,文件類型不支持! (1015).");
        }
        if(!m_allowedFilesList.isEmpty()&&
            !m_allowedFilesList.contains(fileExt)){
          throw new SmartUploadException(
              "上傳文件失敗,文件類型不支持! (1010).");
        }
        if(m_maxFileSize>(long)0&&
            (long)((m_endData-m_startData)+1)>m_maxFileSize){
          throw new SmartUploadException(String.valueOf((new StringBuffer(
              "上傳文件失敗,文件太大: ")).append(fileName).append(
              " (1105).")));
        }
        totalFileSize+=(m_endData-m_startData)+1;
        if(m_totalMaxFileSize>(long)0&&totalFileSize>m_totalMaxFileSize){
          throw new SmartUploadException("上傳文件太大,請重新選擇! (1110).");
        }
        if(totalFileSize<1){
          throw new SmartUploadException("上傳文件沒有內容,請重新選擇! (1110).");
        }
      }
      if(isFile){
        com.westerasoft.util.jspsmart.upload.File newFile=new com.westerasoft.
            util.
            jspsmart.upload.File();
        newFile.setParent(this);
        newFile.setFieldName(fieldName);
        newFile.setFileName(fileName);
        newFile.setFileExt(fileExt);
        newFile.setFilePathName(filePathName);
        newFile.setIsMissing(filePathName.length()==0);
        newFile.setContentType(contentType);
        newFile.setContentDisp(contentDisp);
        newFile.setTypeMIME(typeMIME);
        newFile.setSubTypeMIME(subTypeMIME);
        if(contentType.indexOf("application/x-macbinary")>0){
          m_startData=m_startData+128;
        }
        newFile.setSize((m_endData-m_startData)+1);
        newFile.setStartData(m_startData);
        newFile.setEndData(m_endData);
        m_files.addFile(newFile);
      } else{
        String value=new String(m_binArray,m_startData,
            (m_endData-m_startData)+1);
        m_formRequest.putParameter(fieldName,value);
      }
      if((char)m_binArray[m_currentIndex+1]=='-'){
        break;
      }
      m_currentIndex=m_currentIndex+2;
    } while(true);
  }

  public int save(String destPathName) throws SmartUploadException,IOException,
      ServletException{
    return save(destPathName,0);
  }

  public int save(String destPathName,int option) throws SmartUploadException,
      IOException,ServletException{
    int count=0;
    if(destPathName==null){
      destPathName=m_application.getRealPath("/");
    }
    if(destPathName.indexOf("/")!=-1){
      if(destPathName.charAt(destPathName.length()-1)!='/'){
        destPathName=String.valueOf(destPathName).concat("/");
      }
    } else{
      if(destPathName.charAt(destPathName.length()-1)!='\\'){
        destPathName=String.valueOf(destPathName).concat("\\");
      }
    }
    for(int i=0;i<m_files.getCount();i++){
      if(!m_files.getFile(i).isMissing()){
        m_files.getFile(i).saveAs(destPathName+m_files.getFile(i).getFileName(),
            option);
        count++;
      }
    }

    return count;
  }

  public int getSize(){
    return m_totalBytes;
  }

  public byte getBinaryData(int index){
    byte retval;
    try{
      retval=m_binArray[index];
    } catch(Exception e){
      throw new ArrayIndexOutOfBoundsException("Index out of range (1005).");
    }
    return retval;
  }

  public Files getFiles(){
    return m_files;
  }

  public Request getRequest(){
    return m_formRequest;
  }

  public void downloadFile(String sourceFilePathName) throws
      SmartUploadException,IOException,ServletException{
    downloadFile(sourceFilePathName,null,null);
  }

  public void downloadFile(String sourceFilePathName,String contentType) throws
      SmartUploadException,IOException,ServletException{
    downloadFile(sourceFilePathName,contentType,null);
  }

  public void downloadFile(String sourceFilePathName,String contentType,
      String destFileName) throws SmartUploadException,
      IOException,ServletException{
    downloadFile(sourceFilePathName,contentType,destFileName,65000);
  }

  public void downloadFile(String sourceFilePathName,String contentType,
      String destFileName,
      int blockSize) throws SmartUploadException,
      IOException,ServletException{
    if(sourceFilePathName==null){
      throw new IllegalArgumentException(String.valueOf((new StringBuffer(
          "File '")).
          append(sourceFilePathName).append("' not found (1040).")));
    }
    if(sourceFilePathName.equals("")){
      throw new IllegalArgumentException(String.valueOf((new StringBuffer(
          "File '")).
          append(sourceFilePathName).append("' not found (1040).")));
    }
    if(!isVirtual(sourceFilePathName)&&m_denyPhysicalPath){
      throw new SmartUploadException("Physical path is denied (1035).");
    }
    if(isVirtual(sourceFilePathName)){
      sourceFilePathName=m_application.getRealPath(sourceFilePathName);

    }
    File file=new File(sourceFilePathName);
    FileInputStream fileIn=new FileInputStream(file);
    long fileLen=file.length();
    int readBytes=0;
    int totalRead=0;
    byte b[]=new byte[blockSize];
    if(contentType==null){
      m_response.setContentType("application/x-msdownload");
    } else{
      if(contentType.length()==0){
        m_response.setContentType("application/x-msdownload");
      } else{
        m_response.setContentType(contentType);
      }
    }
    m_response.setContentLength((int)fileLen);
    if(destFileName==null){
      m_response.setHeader("Content-Disposition",
          "attachment; filename="+
          toUtf8String(this.getFileName(sourceFilePathName)));
    } else{
      if(destFileName.length()==0){
        m_response.setHeader("Content-Disposition","attachment;");
      } else{
        m_response.setHeader("Content-Disposition",
            "attachment; filename="+
            toUtf8String(this.getFileName(sourceFilePathName)));
      }
    } while((long)totalRead<fileLen){
      readBytes=fileIn.read(b,0,blockSize);
      totalRead+=readBytes;
      m_response.getOutputStream().write(b,0,readBytes);
    }
    fileIn.close();
  }

  public void downloadFile(byte[] buffer,String contentType,
      String destFileName) throws SmartUploadException,
      IOException,ServletException{
    int readBytes=0;
    int totalRead=0;
    byte b[]=buffer;
    if(contentType==null){
      m_response.setContentType("application/x-msdownload");
    } else{
      if(contentType.length()==0){
        m_response.setContentType("application/x-msdownload");
      } else{
        m_response.setContentType(contentType);
      }
    }
    if(destFileName==null){
      m_response.setHeader("Content-Disposition",
          "attachment; filename="+
          toUtf8String(destFileName));
    } else{
      if(destFileName.length()==0){
        m_response.setHeader("Content-Disposition","attachment;");
      } else{
        m_response.setHeader("Content-Disposition",
            "attachment; filename="+
            toUtf8String(destFileName));
      }
    }
    m_response.getOutputStream().write(buffer, 0, buffer.length);
  }

  //YunFan add the new method in 2003-12-19
  public void downloadField(ResultSet rs,String columnName,String contentType,
      String destFileName,String DataBaseType) throws
      SQLException,IOException,ServletException{
    if(rs==null){
      throw new IllegalArgumentException("The RecordSet cannot be null (1045).");
    }
    if(columnName==null){
      throw new IllegalArgumentException(
          "The columnName cannot be null (1050).");
    }
    if(columnName.length()==0){
      throw new IllegalArgumentException(
          "The columnName cannot be empty (1055).");
    }

    if(DataBaseType.equalsIgnoreCase("oracle")){
      java.sql.Blob myReadBlob=rs.getBlob(columnName);

      int ln=(int)myReadBlob.length();
      java.io.InputStream readis=myReadBlob.getBinaryStream();
      //System.out.println("文件大小:" + ln);
      byte b[]=new byte[ln];
      for(int j=0;j<ln;j++){
        byte l=(byte)readis.read();
        b[j]=l;
      }
      m_response.resetBuffer();
      if(contentType==null){
        m_response.setContentType("application/x-msdownload");
      } else
      if(contentType.length()==0){
        m_response.setContentType("application/x-msdownload");
      } else{
        m_response.setContentType(contentType);
      }
      if(destFileName==null){
        m_response.setHeader("Content-Disposition","attachment;");
      } else
      if(destFileName.length()==0){
        m_response.setHeader("Content-Disposition","attachment;");
      } else{
        destFileName=new String(destFileName.getBytes("GB2312"),"ISO8859-1");
        m_response.setHeader("Content-Disposition",
            "attachment; filename=".
            concat(String.valueOf(destFileName)));
      }
      m_response.getOutputStream().write(b,0,b.length);

    } else{
      byte b[]=rs.getBytes(columnName);
      if(contentType==null){
        m_response.setContentType("application/x-msdownload");
      } else
      if(contentType.length()==0){
        m_response.setContentType("application/x-msdownload");
      } else{
        m_response.setContentType(contentType);
      }
      m_response.setContentLength(b.length);
      if(destFileName==null){
        m_response.setHeader("Content-Disposition","attachment;");

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
宅男噜噜噜66一区二区66| 久久精品水蜜桃av综合天堂| 日韩视频永久免费| 中文字幕 久热精品 视频在线| 一区二区三区精密机械公司| 韩国女主播一区| 欧美三级欧美一级| 亚洲欧美一区二区在线观看| 美国十次了思思久久精品导航| 色狠狠桃花综合| 国产色爱av资源综合区| 蜜臀av在线播放一区二区三区| 91在线精品秘密一区二区| 久久亚洲精品国产精品紫薇| 日欧美一区二区| 日本精品一级二级| 国产精品成人一区二区艾草| 国产一区二区调教| 日韩一区二区精品| 亚洲高清免费观看| 欧美视频在线播放| 亚洲图片欧美一区| 色94色欧美sute亚洲线路一ni | 色欧美片视频在线观看在线视频| 久久久亚洲精品一区二区三区 | 亚洲精品欧美二区三区中文字幕| 国产成人亚洲精品狼色在线 | 欧美精品18+| 亚洲一区二区高清| 欧美日韩三级一区二区| 亚洲国产一区在线观看| 欧美午夜精品一区| 亚洲国产日韩一级| 在线成人免费观看| 日韩高清一级片| 在线不卡免费av| 久久黄色级2电影| 日韩午夜激情电影| 国产伦精品一区二区三区视频青涩 | 福利视频网站一区二区三区| 精品精品国产高清一毛片一天堂| 久久国产精品无码网站| 精品国产乱码久久久久久久 | 久久你懂得1024| 成人午夜大片免费观看| 亚洲免费观看在线视频| 一本一本久久a久久精品综合麻豆 一本一道波多野结衣一区二区 | 亚洲欧洲成人自拍| 在线一区二区三区| 同产精品九九九| 精品三级av在线| 国产精品456| 亚洲青青青在线视频| 欧美在线看片a免费观看| 天堂影院一区二区| 久久亚洲精品国产精品紫薇| av一区二区三区在线| 亚洲一区二区三区四区在线免费观看 | 欧美视频一区二区在线观看| 日韩高清中文字幕一区| 久久久久久99精品| 色呦呦国产精品| 奇米综合一区二区三区精品视频| 精品少妇一区二区三区日产乱码| 国产成人综合在线播放| 亚洲欧美aⅴ...| 日韩免费一区二区| 色综合久久综合网| 国产毛片精品视频| 一区二区三区精品视频| 精品久久久久一区二区国产| 成人黄色电影在线| 午夜电影一区二区三区| 日本一二三四高清不卡| 制服丝袜亚洲色图| 成人精品国产一区二区4080| 日本视频中文字幕一区二区三区| 久久久久久久久岛国免费| 色噜噜久久综合| 国产成人精品免费看| 午夜精品久久久久久| 国产欧美一区二区精品仙草咪| 9191成人精品久久| 91丨九色porny丨蝌蚪| 久色婷婷小香蕉久久| 亚洲欧美激情插| 国产人妖乱国产精品人妖| 欧美一二三区精品| 日本道免费精品一区二区三区| 韩国av一区二区三区在线观看| 亚洲一卡二卡三卡四卡无卡久久| 久久免费看少妇高潮| 日韩欧美黄色影院| 欧美精品在线观看播放| 色噜噜狠狠一区二区三区果冻| 国产成人免费视频网站高清观看视频| 日韩黄色片在线观看| 亚洲三级在线免费| 中国av一区二区三区| 精品剧情v国产在线观看在线| 欧美日韩黄色影视| 在线观看日韩毛片| 99久久99久久精品国产片果冻| 国产一区二区三区免费观看 | 亚洲午夜激情网页| 亚洲欧美日韩国产中文在线| 国产精品视频在线看| 久久丝袜美腿综合| 久久久国产综合精品女国产盗摄| 欧美成人精品高清在线播放| 欧美一区二区三区喷汁尤物| 欧美性videosxxxxx| 欧美日韩一区成人| 欧美日韩视频在线观看一区二区三区 | 99免费精品在线| 99国内精品久久| 97久久超碰精品国产| 99视频超级精品| 91视频免费观看| 色综合久久久久综合体| 日本韩国一区二区三区视频| 91久久精品网| 欧美日韩国产a| 欧美高清视频不卡网| 日韩一级成人av| 26uuu国产电影一区二区| 国产视频亚洲色图| 亚洲人成网站影音先锋播放| 亚洲精品国产成人久久av盗摄| 一区二区三区影院| 午夜激情综合网| 激情综合一区二区三区| 国产电影精品久久禁18| 99久久久无码国产精品| 欧美亚洲国产bt| 日韩一级完整毛片| 久久久久99精品国产片| 中文字幕中文字幕在线一区 | 成人免费小视频| 亚洲一区二区欧美| 久久精品免费观看| 成人av网站在线| 欧美精品国产精品| 久久综合九色综合欧美98| 中文字幕一区二区三区四区不卡| 亚洲欧洲制服丝袜| 日本欧美一区二区在线观看| 国产精品一品二品| 91久久奴性调教| 久久久久久久久99精品| 亚洲蜜臀av乱码久久精品蜜桃| 日本不卡一二三| 成人a免费在线看| 欧美一区二区三区日韩| 国产精品久久久久久一区二区三区 | 亚洲色图制服丝袜| 久久国产尿小便嘘嘘| 91小视频免费观看| 精品国产乱子伦一区| 亚洲狠狠丁香婷婷综合久久久| 久久av资源网| 欧美自拍偷拍一区| 国产亚洲欧美在线| 日产欧产美韩系列久久99| 成人一区二区三区在线观看| 欧美精品在线视频| 亚洲视频一二三区| 国产一区二区91| 欧美一区二区在线观看| 亚洲欧美另类小说视频| 国内久久婷婷综合| 在线视频欧美精品| 国产精品婷婷午夜在线观看| 日本不卡1234视频| 欧美日韩一区二区在线观看视频 | 99久久免费精品| 久久精品亚洲乱码伦伦中文| 亚洲成人在线网站| 色哟哟精品一区| 日本一二三不卡| 老司机精品视频线观看86| 欧美性高清videossexo| 国产精品高潮呻吟| 国产在线一区观看| 精品精品国产高清a毛片牛牛| 五月天丁香久久| 在线亚洲一区二区| 最新国产の精品合集bt伙计| 国产aⅴ综合色| 久久蜜桃av一区精品变态类天堂| 日本一不卡视频| 91精品国产麻豆国产自产在线| 亚洲欧美色图小说| 91免费精品国自产拍在线不卡| 国产精品午夜在线| 成人精品国产一区二区4080| 国产精品久久久久四虎| 懂色av一区二区三区免费看| 久久影院电视剧免费观看| 九九国产精品视频|