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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? streamedattachments.java

?? Xfire文件 用于開發(fā)web service 的一個開源工具 很好用的
?? JAVA
字號:
package org.codehaus.xfire.attachments;import java.io.File;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.io.PushbackInputStream;import java.util.ArrayList;import java.util.Enumeration;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import javax.activation.DataHandler;import javax.activation.DataSource;import javax.mail.Header;import javax.mail.MessagingException;import javax.mail.internet.InternetHeaders;import org.codehaus.xfire.MessageContext;import org.codehaus.xfire.XFireRuntimeException;import org.codehaus.xfire.util.CachedOutputStream;public class StreamedAttachments    implements Attachments{    public static final String ATTACHMENT_DIRECTORY = "attachment-directory";    public static final String ATTACHMENT_MEMORY_THRESHOLD = "attachment-memory-threshold";    private static final String NO_TEMP_ERR = "Unable to write tempoary files.  "            + "No temporary directory configured, and security settings prohibit "            + "access to the \"java.io.tmpdir\" property.";    private boolean soapMessageRead = false;    private PushbackInputStream stream;    private String boundary;    private int threshold = 1024 * 100;    private File tempDirectory;    private Map parts = new HashMap();    private Attachment soapMessage;    private String contentType;    private List cache = new ArrayList();    private MessageContext context;    public StreamedAttachments(InputStream is, String contentType) throws IOException    {        this(null, is, contentType);    }    public StreamedAttachments(MessageContext context, InputStream is, String contentType)            throws IOException    {        int i = contentType.indexOf("boundary=\"");        int end;        int len;        if (i == -1)        {            i = contentType.indexOf("boundary=");            end = contentType.indexOf(";", i + 9);            if (end == -1)                end = contentType.length();            len = 9;        }        else        {            end = contentType.indexOf("\"", i + 10);            len = 10;        }        if (i == -1 || end == -1)            throw new IOException("Invalid content type: missing boundary! " + contentType);        this.boundary = "--" + contentType.substring(i + len, end);        this.stream = new PushbackInputStream(is, boundary.length());        this.contentType = contentType;        if (!readTillFirstBoundary(stream, boundary.getBytes()))            throw new IOException("Couldn't find MIME boundary: " + boundary);        this.context = context;    }    public void addPart(Attachment part)    {        throw new UnsupportedOperationException();    }    public String getContentType()    {        return contentType;    }    public Attachment getPart(String id)    {        if (!parts.containsKey(id))            readTo(id);        return (Attachment) parts.get(id);    }    public Iterator getParts()    {        ensureAllPartsRead();        return parts.values().iterator();    }    public String getSoapContentType()    {        ensureSoapAttachmentIsRead();        return soapMessage.getHeader("Content-Type");    }    public Attachment getSoapMessage()    {        ensureSoapAttachmentIsRead();        return soapMessage;    }    private void ensureSoapAttachmentIsRead()    {        if (soapMessageRead)            return;        try        {            soapMessage = readNextAttachment();            soapMessageRead = true;        }        catch (IOException e)        {            throw new XFireRuntimeException("Could not read message!", e);        }    }    private void ensureAllPartsRead()    {        readTo(null);    }    private void readTo(String id)    {        ensureSoapAttachmentIsRead();        try        {            for (Attachment a = readNextAttachment(); a != null; a = readNextAttachment())            {                parts.put(a.getId(), a);                if (a != null && id != null && a.getId().equals(id))                    return;            }        }        catch (IOException e)        {            throw new XFireRuntimeException("Could not read message!", e);        }    }    private Attachment readNextAttachment()        throws IOException    {        int v = stream.read();        if (v == -1)            return null;        stream.unread(v);        try        {            InternetHeaders headers = new InternetHeaders(stream);            MimeBodyPartInputStream partStream = new MimeBodyPartInputStream(stream, boundary                    .getBytes());            final CachedOutputStream cos = new CachedOutputStream(getThreshold(),                    getTempDirectory());            copy(partStream, cos);            final String ct = headers.getHeader("Content-Type", null);            cache.add(cos);            DataSource source = new AttachmentDataSource(ct, cos);            DataHandler dh = new DataHandler(source);            String id = headers.getHeader("Content-ID", null);            if (id != null && id.startsWith("<"))            {                id = id.substring(1, id.length() - 1);            }            SimpleAttachment att = new SimpleAttachment(id, dh);            for (Enumeration e = headers.getAllHeaders(); e.hasMoreElements();)            {                Header header = (Header) e.nextElement();                att.setHeader(header.getName(), header.getValue());            }            return att;        }        catch (MessagingException e)        {            throw new IOException("Couldn't read headers.");        }    }    public void setSoapContentType(String soapMimeType)    {        throw new UnsupportedOperationException();    }    public void setSoapMessage(Attachment soapMessage)    {        throw new UnsupportedOperationException();    }    public int size()    {        ensureAllPartsRead();        return parts.size();    }    public void write(OutputStream out)        throws IOException    {        throw new UnsupportedOperationException();    }    public void dispose()    {        for (Iterator itr = cache.iterator(); itr.hasNext();)        {            CachedOutputStream cos = (CachedOutputStream) itr.next();            cos.dispose();        }    }    /**     * The directory where attachments will be written to if they exceed the     * Threshold.     *      * @return     */    public File getTempDirectory()    {        File td = null;        if (context != null)        {            Object value = context.getContextualProperty(ATTACHMENT_DIRECTORY);            if (value instanceof File)            {                td = (File) value;            }            else if (value != null)            {                td = new File((String) value);            }        }        if (td == null)        {            td = tempDirectory;        }        if (td == null)        {            String defaultTempDir;            try            {                defaultTempDir = System.getProperty("java.io.tmpdir");            }            catch (SecurityException se)            {                throw new IllegalStateException(NO_TEMP_ERR);            }            td = new File(defaultTempDir);        }        return td;    }    public void setTempDirectory(File tempDirectory)    {        this.tempDirectory = tempDirectory;    }    /**     * Get the threshold in bytes. The threshold is the size an attachment needs     * to reach before it is written to a temporary directory.     *      * @return     */    public int getThreshold()    {        if (context != null)        {            Object tObj = context.getContextualProperty(ATTACHMENT_MEMORY_THRESHOLD);            if (tObj != null)            {                if (tObj instanceof Integer)                {                    Integer t = (Integer) tObj;                    return t.intValue();                }                return Integer.valueOf(tObj.toString()).intValue();            }        }        return threshold;    }    public void setThreshold(int threshold)    {        this.threshold = threshold;    }    protected static void copy(InputStream input, OutputStream output)        throws IOException    {        try        {            final byte[] buffer = new byte[8096];            int n = input.read(buffer);            while (n > 0)            {                output.write(buffer, 0, n);                n = input.read(buffer);            }        }        finally        {            input.close();            output.close();        }    }    /**     * Move the read pointer to the begining of the first part read till the end     * of first boundary     *      * @param pushbackInStream     * @param boundary     * @throws MessagingException     */    private boolean readTillFirstBoundary(PushbackInputStream pushbackInStream, byte[] boundary)        throws IOException    {        // work around a bug in PushBackInputStream where the buffer isn't        // initialized        // and available always returns 0.        int value = pushbackInStream.read();        pushbackInStream.unread(value);        while (value != -1)        {            value = pushbackInStream.read();            if ((byte) value == boundary[0])            {                int boundaryIndex = 0;                while (value != -1 && (boundaryIndex < boundary.length)                        && ((byte) value == boundary[boundaryIndex]))                {                    value = pushbackInStream.read();                    if (value == -1)                        throw new IOException(                                "Unexpected End of Stream while searching for first Mime Boundary");                    boundaryIndex++;                }                if (boundaryIndex == boundary.length)                { // boundary found                    pushbackInStream.read();                    return true;                }            }        }        return false;    }    private class MimeBodyPartInputStream        extends InputStream    {        PushbackInputStream inStream;        boolean boundaryFound = false;        byte[] boundary;        public MimeBodyPartInputStream(PushbackInputStream inStream, byte[] boundary)        {            super();            this.inStream = inStream;            this.boundary = boundary;        }        public int read()            throws IOException        {            if (boundaryFound)            {                return -1;            }            // read the next value from stream            int value = inStream.read();            // Used to add back a new line if a boundary is not found.            boolean encounteredNewLine = false;            // A problem occured because all the mime parts tends to have a /r/n            // at the end. Making it hard to transform them to correct            // DataSources.            // This logic introduced to handle it            // TODO look more in to this && for a better way to do this            if (value == 13)            {                value = inStream.read();                if (value != 10)                {                    inStream.unread(value);                    return 13;                }                else                {                    value = inStream.read();                    if ((byte) value != boundary[0])                    {                        inStream.unread(value);                        inStream.unread(10);                        return 13;                    }                    else                    {                        encounteredNewLine = true;                    }                }            }            else if ((byte) value != boundary[0])            {                return value;            }            // read value is the first byte of the boundary. Start matching the            // next characters to find a boundary            int boundaryIndex = 0;            while ((boundaryIndex < boundary.length) && ((byte) value == boundary[boundaryIndex]))            {                value = inStream.read();                boundaryIndex++;            }            if (boundaryIndex == boundary.length)            { // boundary found                boundaryFound = true;                // read the end of line character                if (inStream.read() == 45 && value == 45)                {                    // Last mime boundary should have a succeeding "--"                    // as we are on it, read the terminating CRLF                    int value1 = inStream.read();                    int value2 = inStream.read();                }                return -1;            }            // Boundary not found. Restoring bytes skipped.            // write first skipped byte, push back the rest            if (value != -1)            { // Stream might have ended                inStream.unread(value);            }            inStream.unread(boundary, 1, boundaryIndex - 1);            if (encounteredNewLine)            {                // Put back 45                inStream.unread(boundary[0]);                // Put back 10                inStream.unread(10);                // Return the first character we read.                return 13;            }            else            {                // No new line encountered, return as usual.                return boundary[0];            }        }    }}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲777理论| 成人性生交大片免费看在线播放| 久久久精品免费免费| 91麻豆.com| 国产一区二区三区四区五区入口| 亚洲人快播电影网| 久久精品一区蜜桃臀影院| 欧美日韩免费电影| 99在线精品观看| 国产综合一区二区| 五月综合激情婷婷六月色窝| 国产精品电影院| 精品久久国产老人久久综合| 欧美写真视频网站| 91原创在线视频| 成人午夜视频网站| 国产91精品一区二区麻豆网站| 免费欧美日韩国产三级电影| 亚洲午夜久久久久久久久电影网 | 久久精品人人做人人综合| 欧美丰满高潮xxxx喷水动漫| 一本到不卡精品视频在线观看| 国产成人免费视频网站| 国产一区二区免费视频| 乱一区二区av| 蜜臀91精品一区二区三区| 无码av免费一区二区三区试看 | 亚洲激情在线激情| 国产精品嫩草久久久久| 久久久久久久久久久黄色 | 亚洲在线成人精品| 亚洲日本中文字幕区| 欧美国产激情一区二区三区蜜月| 久久久久久一级片| 久久久国产一区二区三区四区小说 | 日韩av电影天堂| 天天av天天翘天天综合网色鬼国产 | 精品一区二区三区视频在线观看| 日韩精品电影在线| 日韩av在线播放中文字幕| 日韩精彩视频在线观看| 日韩福利视频导航| 精品亚洲成av人在线观看| 狠狠色丁香九九婷婷综合五月| 国产一区二区三区四区在线观看| 国产麻豆精品theporn| 国产精品伊人色| 国产91精品久久久久久久网曝门| 白白色 亚洲乱淫| 波多野结衣中文字幕一区 | 欧美丰满美乳xxx高潮www| 91精品视频网| 精品久久久久久最新网址| 国产亚洲自拍一区| 亚洲欧美一区二区在线观看| 亚洲美女一区二区三区| 亚洲成人久久影院| 人人超碰91尤物精品国产| 麻豆精品一二三| 国产精品一卡二卡在线观看| jizzjizzjizz欧美| 欧美亚洲国产bt| 欧美一卡二卡三卡四卡| 久久亚洲精华国产精华液| 国产精品素人视频| 亚洲与欧洲av电影| 九一久久久久久| www.日韩av| 欧美日韩高清影院| 久久综合九色综合97_久久久| 中文字幕在线不卡视频| 亚洲国产精品久久一线不卡| 黄页视频在线91| 91亚洲精品久久久蜜桃| 91精品国产综合久久福利| 久久久国产精品不卡| 亚洲精品免费在线播放| 青青青爽久久午夜综合久久午夜| 国产成人综合亚洲网站| 欧美午夜在线一二页| 久久久蜜臀国产一区二区| 一区二区三区日韩| 狠狠色丁香久久婷婷综| 欧美性生活大片视频| 久久综合九色综合欧美就去吻| 亚洲精品免费电影| 国产一区二区三区最好精华液| 在线影视一区二区三区| 久久免费午夜影院| 三级欧美在线一区| 波多野结衣欧美| 精品国产乱码91久久久久久网站| 亚洲色图在线视频| 国产一区欧美二区| 欧美日韩激情一区二区| 国产精品国产a| 黄色成人免费在线| 91精品国产综合久久福利| 亚洲男人的天堂在线观看| 黄色日韩三级电影| 欧美精品一二三| 亚洲人成网站精品片在线观看| 国产麻豆欧美日韩一区| 91麻豆精品国产91久久久久久久久| 中文字幕亚洲电影| 国产一区二区三区电影在线观看| 欧美裸体bbwbbwbbw| 亚洲人123区| 成人av电影在线网| 精品理论电影在线| 日韩精品一卡二卡三卡四卡无卡| 在线视频国内自拍亚洲视频| 国产精品网站在线观看| 国产乱理伦片在线观看夜一区| 91精品国产福利| 午夜婷婷国产麻豆精品| 91色视频在线| 中文字幕一区二区三| 国产成人av电影免费在线观看| 日韩欧美的一区| 青青草91视频| 欧美日韩国产不卡| 亚洲成人一区二区| 在线视频国内自拍亚洲视频| 亚洲人妖av一区二区| yourporn久久国产精品| 国产精品麻豆一区二区| 成人一道本在线| 欧美国产禁国产网站cc| 成人综合日日夜夜| 国产精品女人毛片| 成人av影视在线观看| 国产精品麻豆久久久| 成人黄色777网| 国产精品久久99| av中文字幕一区| 玉足女爽爽91| 在线观看成人免费视频| 亚洲成人高清在线| 在线综合视频播放| 国内精品伊人久久久久影院对白| 欧美成人在线直播| 国产精品一二三四五| 国产日韩欧美麻豆| 成人高清视频免费观看| 亚洲欧美偷拍三级| 欧美日韩国产综合久久| 日本不卡视频一二三区| 欧美精品一区二区久久久| 国产精品中文欧美| 亚洲色图一区二区三区| 欧美三级一区二区| 蜜臀久久99精品久久久画质超高清 | 欧美一区二区三区在线观看| 亚洲成人av电影| 3d成人动漫网站| 国内成人免费视频| 国产精品拍天天在线| 91福利在线观看| 日本aⅴ亚洲精品中文乱码| 久久一日本道色综合| av一区二区三区| 五月综合激情日本mⅴ| 精品剧情v国产在线观看在线| 成人的网站免费观看| 亚洲一区电影777| 日韩一级成人av| eeuss鲁片一区二区三区| 亚洲不卡一区二区三区| 精品国产sm最大网站| 972aa.com艺术欧美| 日韩国产在线观看| 亚洲国产成人自拍| 欧美日韩精品欧美日韩精品一 | 最新欧美精品一区二区三区| 在线亚洲一区二区| 激情综合色综合久久综合| 亚洲精品欧美激情| 精品卡一卡二卡三卡四在线| 一本到高清视频免费精品| 美女网站色91| 玉米视频成人免费看| 久久婷婷国产综合国色天香 | 99久久精品国产毛片| 日韩av电影免费观看高清完整版在线观看| 久久久精品一品道一区| 欧美日本国产一区| 成人精品鲁一区一区二区| 日韩制服丝袜av| 亚洲欧美日本韩国| 国产亚洲欧洲一区高清在线观看| 在线免费观看日韩欧美| 国产精品18久久久久久vr| 婷婷六月综合亚洲| 中文字幕中文字幕在线一区 | 在线视频国产一区| 国产成人精品一区二区三区四区 | 欧美在线免费播放| 欧美唯美清纯偷拍| 亚洲h精品动漫在线观看|