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

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

?? diskfileitem.java

?? 解觖java技術中后臺無法上傳數(shù)給的情況
?? JAVA
?? 第 1 頁 / 共 2 頁
字號:
/*
 * Copyright 2001-2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.myvietnam.mvncore.web.fileupload.disk;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.ObjectOutputStream;
import java.io.ObjectInputStream;
import java.io.UnsupportedEncodingException;
import java.rmi.server.UID;
import java.util.Map;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.FileCleaner;
import org.apache.commons.io.output.DeferredFileOutputStream;

import net.myvietnam.mvncore.web.fileupload.FileItem;
import net.myvietnam.mvncore.web.fileupload.FileUploadException;
import net.myvietnam.mvncore.web.fileupload.ParameterParser;


/**
 * <p> The default implementation of the
 * {@link org.apache.commons.fileupload.FileItem FileItem} interface.
 *
 * <p> After retrieving an instance of this class from a {@link
 * org.apache.commons.fileupload.DiskFileUpload DiskFileUpload} instance (see
 * {@link org.apache.commons.fileupload.DiskFileUpload
 * #parseRequest(javax.servlet.http.HttpServletRequest)}), you may
 * either request all contents of file at once using {@link #get()} or
 * request an {@link java.io.InputStream InputStream} with
 * {@link #getInputStream()} and process the file without attempting to load
 * it into memory, which may come handy with large files.
 *
 * @author <a href="mailto:Rafal.Krzewski@e-point.pl">Rafal Krzewski</a>
 * @author <a href="mailto:sean@informage.net">Sean Legassick</a>
 * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
 * @author <a href="mailto:jmcnally@apache.org">John McNally</a>
 * @author <a href="mailto:martinc@apache.org">Martin Cooper</a>
 * @author Sean C. Sullivan
 *
 * @since FileUpload 1.1
 *
 * @version $Id: DiskFileItem.java,v 1.2 2006/02/12 04:43:11 minhnn Exp $
 */
public class DiskFileItem
    implements FileItem {

    // ----------------------------------------------------- Manifest constants


    /**
     * Default content charset to be used when no explicit charset
     * parameter is provided by the sender. Media subtypes of the
     * "text" type are defined to have a default charset value of
     * "ISO-8859-1" when received via HTTP.
     */
    public static final String DEFAULT_CHARSET = "ISO-8859-1";


    // ----------------------------------------------------------- Data members


    /**
     * UID used in unique file name generation.
     */
    private static final String UID =
            new UID().toString().replace(':', '_').replace('-', '_');

    /**
     * Counter used in unique identifier generation.
     */
    private static int counter = 0;


    /**
     * The name of the form field as provided by the browser.
     */
    private String fieldName;


    /**
     * The content type passed by the browser, or <code>null</code> if
     * not defined.
     */
    private String contentType;


    /**
     * Whether or not this item is a simple form field.
     */
    private boolean isFormField;


    /**
     * The original filename in the user's filesystem.
     */
    private String fileName;


    /**
     * The threshold above which uploads will be stored on disk.
     */
    private int sizeThreshold;


    /**
     * The directory in which uploaded files will be stored, if stored on disk.
     */
    private File repository;


    /**
     * Cached contents of the file.
     */
    private byte[] cachedContent;


    /**
     * Output stream for this item.
     */
    private transient DeferredFileOutputStream dfos;

    /**
     * File to allow for serialization of the content of this item.
     */
    private File dfosFile;


    // ----------------------------------------------------------- Constructors


    /**
     * Constructs a new <code>DiskFileItem</code> instance.
     *
     * @param fieldName     The name of the form field.
     * @param contentType   The content type passed by the browser or
     *                      <code>null</code> if not specified.
     * @param isFormField   Whether or not this item is a plain form field, as
     *                      opposed to a file upload.
     * @param fileName      The original filename in the user's filesystem, or
     *                      <code>null</code> if not specified.
     * @param sizeThreshold The threshold, in bytes, below which items will be
     *                      retained in memory and above which they will be
     *                      stored as a file.
     * @param repository    The data repository, which is the directory in
     *                      which files will be created, should the item size
     *                      exceed the threshold.
     */
    public DiskFileItem(String fieldName, String contentType,
            boolean isFormField, String fileName, int sizeThreshold,
            File repository) {
        this.fieldName = fieldName;
        this.contentType = contentType;
        this.isFormField = isFormField;
        this.fileName = fileName;
        this.sizeThreshold = sizeThreshold;
        this.repository = repository;
    }


    // ------------------------------- Methods from javax.activation.DataSource


    /**
     * Returns an {@link java.io.InputStream InputStream} that can be
     * used to retrieve the contents of the file.
     *
     * @return An {@link java.io.InputStream InputStream} that can be
     *         used to retrieve the contents of the file.
     *
     * @throws IOException if an error occurs.
     */
    public InputStream getInputStream()
        throws IOException {
        if (!isInMemory()) {
            return new FileInputStream(dfos.getFile());
        }

        if (cachedContent == null) {
            cachedContent = dfos.getData();
        }
        return new ByteArrayInputStream(cachedContent);
    }


    /**
     * Returns the content type passed by the agent or <code>null</code> if
     * not defined.
     *
     * @return The content type passed by the agent or <code>null</code> if
     *         not defined.
     */
    public String getContentType() {
        return contentType;
    }


    /**
     * Returns the content charset passed by the agent or <code>null</code> if
     * not defined.
     *
     * @return The content charset passed by the agent or <code>null</code> if
     *         not defined.
     */
    public String getCharSet() {
        ParameterParser parser = new ParameterParser();
        parser.setLowerCaseNames(true);
        // Parameter parser can handle null input
        Map params = parser.parse(getContentType(), ';');
        return (String) params.get("charset");
    }


    /**
     * Returns the original filename in the client's filesystem.
     *
     * @return The original filename in the client's filesystem.
     */
    public String getName() {
        return fileName;
    }


    // ------------------------------------------------------- FileItem methods


    /**
     * Provides a hint as to whether or not the file contents will be read
     * from memory.
     *
     * @return <code>true</code> if the file contents will be read
     *         from memory; <code>false</code> otherwise.
     */
    public boolean isInMemory() {
        if (cachedContent != null) {
            return true;
        } else {
            return dfos.isInMemory();
        }
    }


    /**
     * Returns the size of the file.
     *
     * @return The size of the file, in bytes.
     */
    public long getSize() {
        if (cachedContent != null) {
            return cachedContent.length;
        } else if (dfos.isInMemory()) {
            return dfos.getData().length;
        } else {
            return dfos.getFile().length();
        }
    }


    /**
     * Returns the contents of the file as an array of bytes.  If the
     * contents of the file were not yet cached in memory, they will be
     * loaded from the disk storage and cached.
     *
     * @return The contents of the file as an array of bytes.
     */
    public byte[] get() {
        if (isInMemory()) {
            if (cachedContent == null) {
                cachedContent = dfos.getData();
            }
            return cachedContent;
        }

        byte[] fileData = new byte[(int) getSize()];
        FileInputStream fis = null;

        try {
            fis = new FileInputStream(dfos.getFile());
            fis.read(fileData);
        } catch (IOException e) {
            fileData = null;
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (IOException e) {
                    // ignore
                }
            }
        }

        return fileData;
    }


    /**
     * Returns the contents of the file as a String, using the specified
     * encoding.  This method uses {@link #get()} to retrieve the
     * contents of the file.
     *
     * @param charset The charset to use.
     *
     * @return The contents of the file, as a string.
     *
     * @throws UnsupportedEncodingException if the requested character
     *                                      encoding is not available.
     */
    public String getString(final String charset)
        throws UnsupportedEncodingException {
        return new String(get(), charset);
    }


    /**
     * Returns the contents of the file as a String, using the default
     * character encoding.  This method uses {@link #get()} to retrieve the
     * contents of the file.
     *
     * @return The contents of the file, as a string.
     *
     * @todo Consider making this method throw UnsupportedEncodingException.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人毛片老司机大片| 久久久噜噜噜久噜久久综合| 久久亚洲欧美国产精品乐播| 国产精品国产三级国产普通话蜜臀| 亚洲高清免费观看| 99精品久久99久久久久| 2023国产精品| 亚洲chinese男男1069| av成人免费在线观看| 欧美va亚洲va国产综合| 亚洲18女电影在线观看| aa级大片欧美| 欧美激情一区二区三区全黄| 精品在线一区二区三区| 欧美二区三区91| 亚洲国产一区视频| 色婷婷久久久综合中文字幕| 国产精品午夜在线| 成人性生交大片免费看中文| 精品国产免费人成电影在线观看四季 | 欧美日韩一卡二卡三卡 | 一区二区三区av电影| 成人综合在线视频| 国产欧美一区在线| 国产成人精品免费看| 久久精品亚洲精品国产欧美 | 成人小视频免费在线观看| 91精品国产乱码| 日韩精品一二三四| 91精品国产综合久久香蕉的特点| 亚洲一二三四在线| 欧美日韩国产影片| 亚洲123区在线观看| 欧美精选午夜久久久乱码6080| 亚洲国产一二三| 欧美日韩国产大片| 日韩高清不卡一区二区三区| 51精品久久久久久久蜜臀| 亚洲妇女屁股眼交7| 欧美日本乱大交xxxxx| 日韩av在线播放中文字幕| 日韩一区二区三区免费观看| 美女视频黄 久久| 精品福利视频一区二区三区| 国产剧情在线观看一区二区| 亚洲国产精品成人久久综合一区| 成人免费毛片a| 亚洲欧美日韩中文播放| 精品视频色一区| 久久疯狂做爰流白浆xx| 日本一区二区三区四区在线视频 | 国产亚洲一区字幕| 99视频精品免费视频| 亚洲精品国产成人久久av盗摄 | 亚洲婷婷综合色高清在线| 91国偷自产一区二区三区成为亚洲经典 | 在线视频你懂得一区二区三区| 亚洲午夜久久久久| 欧美va亚洲va| 91看片淫黄大片一级| 午夜一区二区三区视频| 精品日韩成人av| k8久久久一区二区三区| 亚洲大型综合色站| 欧美精品一区在线观看| 波波电影院一区二区三区| 国产精品私人影院| 精品视频在线视频| 国产精品911| 亚洲一区二区高清| 欧美成人免费网站| 91国模大尺度私拍在线视频| 日本在线不卡视频| 亚洲三级久久久| 精品久久久久久久人人人人传媒 | ...av二区三区久久精品| 欧美日韩一级二级三级| 国产成人亚洲综合a∨猫咪| 亚洲一区自拍偷拍| 国产色产综合色产在线视频| 欧美图片一区二区三区| 国产成人8x视频一区二区 | 欧美日韩国产高清一区二区| 国产成人免费av在线| 麻豆精品一区二区av白丝在线| 日韩美女视频一区二区| 欧美精品一区二区三区高清aⅴ | 亚洲精品在线免费播放| 欧美日韩一区二区不卡| 99天天综合性| 国产99久久久国产精品潘金| 日本在线观看不卡视频| 一级特黄大欧美久久久| 日韩美女视频一区| 中文字幕不卡三区| 久久女同互慰一区二区三区| 欧美午夜理伦三级在线观看| 成人免费看的视频| 国产福利一区二区三区视频| 久久99热99| 蜜桃传媒麻豆第一区在线观看| 一区二区三区丝袜| 亚洲精品久久久蜜桃| 国产精品系列在线| 国产精品亲子伦对白| 日本一二三不卡| 亚洲国产精品激情在线观看| 久久久久久久综合狠狠综合| 日韩一级完整毛片| 69久久99精品久久久久婷婷| 欧美午夜精品免费| 欧美三级日韩三级国产三级| 91免费国产在线观看| 99久久综合国产精品| 成人av在线一区二区三区| 成人综合在线视频| 99久久免费精品高清特色大片| 成人国产精品免费观看动漫| 99久久免费视频.com| 99re在线视频这里只有精品| 99国产精品99久久久久久| 不卡av在线网| 99久久伊人网影院| 色老汉av一区二区三区| 日本高清免费不卡视频| 在线观看视频一区二区欧美日韩| 在线免费视频一区二区| 欧美三级韩国三级日本一级| 在线成人免费观看| 欧美大片拔萝卜| 国产清纯在线一区二区www| 中文字幕免费不卡| 亚洲欧美日韩国产手机在线 | 久久精品国产精品亚洲综合| 狠狠色丁香久久婷婷综| 国产福利精品导航| 色欧美日韩亚洲| 欧美日韩亚洲高清一区二区| 日韩欧美高清一区| 国产精品视频麻豆| 亚洲电影一区二区三区| 蜜桃av一区二区在线观看| 国产精品123区| 欧美性猛片aaaaaaa做受| 日韩欧美国产一区二区在线播放| 26uuu亚洲综合色| 亚洲欧美一区二区不卡| 奇米色一区二区三区四区| 国产白丝精品91爽爽久久| 欧美四级电影网| 精品福利一区二区三区| 亚洲精品成a人| 久久精品国产精品亚洲红杏| 成人国产一区二区三区精品| 4438亚洲最大| 亚洲视频精选在线| 久久成人久久爱| 欧美综合久久久| xf在线a精品一区二区视频网站| 国产精品女同一区二区三区| 午夜av一区二区| 本田岬高潮一区二区三区| 欧美一级日韩免费不卡| 最新欧美精品一区二区三区| 免费精品视频在线| 91成人在线免费观看| 久久久久久亚洲综合| 五月激情六月综合| 91蜜桃在线观看| 久久久久久久性| 麻豆国产91在线播放| 在线观看国产一区二区| 欧美国产精品v| 精品一区二区三区免费观看| 欧美写真视频网站| 亚洲免费观看高清在线观看| 国产98色在线|日韩| 精品久久久久久久久久久久包黑料 | 337p粉嫩大胆噜噜噜噜噜91av | 7777精品伊人久久久大香线蕉经典版下载| 国产亚洲1区2区3区| 蜜桃久久久久久久| 欧美日韩国产乱码电影| 亚洲欧美怡红院| 成人一级片网址| 久久久亚洲精华液精华液精华液| 日韩二区在线观看| 欧美日韩不卡一区| 亚洲综合一区二区三区| 91视频精品在这里| 亚洲视频一二区| eeuss国产一区二区三区| 久久久久久久综合| 国产精品88av| 久久久99精品久久| 国产精品系列在线观看| 久久九九久精品国产免费直播| 国内精品国产三级国产a久久| 日韩精品在线一区二区| 图片区小说区国产精品视频|