亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
成人国产亚洲欧美成人综合网| 乱中年女人伦av一区二区| 国产精品91一区二区| 国产一区久久久| 国产盗摄一区二区| 91在线免费看| 91精品欧美福利在线观看| 欧美一二三区在线观看| 国产日韩欧美制服另类| 18欧美亚洲精品| 免费观看一级欧美片| 国产一区二区按摩在线观看| 国产99久久久国产精品| 99精品视频一区| 精品处破学生在线二十三| 国产精品短视频| 久久精品国产亚洲a| 成人免费视频视频在线观看免费 | 国产精品嫩草99a| 亚洲最大色网站| 成人av在线播放网站| 欧美一卡2卡3卡4卡| 亚洲视频小说图片| 国模娜娜一区二区三区| 3d成人h动漫网站入口| 国产精品麻豆欧美日韩ww| 久久91精品国产91久久小草| 欧美色男人天堂| 中文字幕中文字幕在线一区 | 粉嫩一区二区三区性色av| 欧美一二区视频| 日韩 欧美一区二区三区| 欧美亚洲高清一区| 亚洲午夜久久久久| 欧美自拍偷拍一区| 亚洲图片欧美色图| 91精品国产色综合久久ai换脸 | 国产精品久久久一区麻豆最新章节| 亚洲444eee在线观看| 欧美日韩国产经典色站一区二区三区| 欧美视频三区在线播放| 亚洲永久精品国产| 91精品在线麻豆| 国产在线观看一区二区| 久久这里只精品最新地址| 成人中文字幕合集| 亚洲乱码中文字幕| 欧美一区二区私人影院日本| 视频一区欧美精品| 国产精品天干天干在观线| 99精品视频免费在线观看| 亚洲成人777| 国产精品久久久久久久久久久免费看| 一本色道**综合亚洲精品蜜桃冫| 一区二区在线看| 欧美精品一区二区三区很污很色的 | 麻豆91小视频| 亚洲女人****多毛耸耸8| 91国产免费看| 福利91精品一区二区三区| 一区二区三区日韩| 久久精品无码一区二区三区| 成人涩涩免费视频| 久久爱www久久做| 亚洲综合一区在线| 亚洲另类中文字| 中文字幕一区二区三区精华液| 欧美一级欧美一级在线播放| 91影视在线播放| 91亚洲精华国产精华精华液| 亚洲一区二区免费视频| 久久亚洲二区三区| 欧美日韩综合在线| 欧美在线观看视频一区二区三区| av一区二区三区| 色综合天天综合给合国产| 99久久精品免费看国产免费软件| 久久久久久久久久久久电影| 在线精品视频免费播放| 色拍拍在线精品视频8848| 一本大道久久精品懂色aⅴ| 成人午夜精品在线| 色综合天天综合网国产成人综合天| 成人av中文字幕| 欧美日韩午夜影院| 欧美日韩日日骚| 精品国产区一区| ...中文天堂在线一区| 日韩黄色片在线观看| 精品午夜久久福利影院| 91亚洲精品乱码久久久久久蜜桃| 在线观看91精品国产入口| 精品免费99久久| 一区二区三区自拍| 国产精品一二三| 欧美一级久久久久久久大片| 久久久久国产精品麻豆| 一区二区欧美视频| 狠狠色狠狠色合久久伊人| 欧美在线三级电影| 专区另类欧美日韩| 国产精品伊人色| 欧美日韩久久久| 国产色产综合产在线视频| 日韩综合小视频| 欧美日本在线观看| 一区二区三区四区激情 | 久久精品在线免费观看| 日本成人中文字幕| 欧美日韩国产成人在线91| 亚洲婷婷综合久久一本伊一区| 国产精品一区三区| 日本一区二区成人| 国产精品亚洲一区二区三区在线| 欧美日精品一区视频| 亚洲成人综合网站| 欧美羞羞免费网站| 久久se精品一区精品二区| 日韩午夜在线影院| 国产综合久久久久影院| 日本一区二区高清| 91女人视频在线观看| 亚洲国产aⅴ成人精品无吗| 欧美日韩国产经典色站一区二区三区| 久久不见久久见免费视频1| 成人免费看黄yyy456| 日本一区二区三区dvd视频在线| 成人免费视频一区二区| 一片黄亚洲嫩模| 精品成人一区二区三区四区| 国内精品视频一区二区三区八戒| 国产日韩欧美精品电影三级在线| 99视频有精品| 国产毛片精品国产一区二区三区| 国产精品无遮挡| 欧美大片在线观看一区二区| 国产成人精品一区二区三区四区 | 极品少妇一区二区三区精品视频| 国产精品系列在线| 日韩一级黄色大片| 欧美色图激情小说| jiyouzz国产精品久久| 国产最新精品免费| 精品一区二区三区香蕉蜜桃| 又紧又大又爽精品一区二区| 26uuu精品一区二区在线观看| 99久久99久久精品免费观看| 精品一区二区三区久久| 日韩成人午夜电影| 五月激情六月综合| 亚洲电影中文字幕在线观看| 国产精品久久久久久久第一福利| 国产日韩欧美高清| 中文字幕日本不卡| 一区二区三区在线影院| 亚洲成人在线网站| 天天爽夜夜爽夜夜爽精品视频| 亚洲高清视频在线| 日韩精品欧美成人高清一区二区| 亚洲成人一二三| 蜜臀精品一区二区三区在线观看 | 久久99久久久欧美国产| 久久99精品国产| 91色|porny| 欧美一卡二卡在线| 国产精品丝袜91| 亚洲国产精品久久人人爱| 久久精品国产精品亚洲综合| 风间由美性色一区二区三区| 欧美精品123区| 日韩三级电影网址| 日韩一区二区三区免费看| 欧美极品xxx| 日韩和欧美的一区| 99久久99久久精品免费观看| 日韩亚洲欧美成人一区| 亚洲美女视频在线| 国产精品一区二区黑丝| 欧美肥大bbwbbw高潮| 亚洲视频免费观看| www.视频一区| 国产夜色精品一区二区av| 亚洲黄色性网站| 不卡一卡二卡三乱码免费网站| 欧美一区二区三区小说| 亚洲与欧洲av电影| 在线观看成人小视频| 一区二区三区视频在线看| 成人av中文字幕| 亚洲精品你懂的| av毛片久久久久**hd| 国产精品免费av| 99精品在线免费| 亚洲bt欧美bt精品777| 欧美影院一区二区| 美日韩黄色大片| 国产目拍亚洲精品99久久精品| 国产一区二区调教| 国产欧美日韩另类一区| aaa欧美日韩|