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

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

?? filenameutils.java

?? < JavaME核心技術最佳實踐>>的全部源代碼
?? JAVA
?? 第 1 頁 / 共 4 頁
字號:
/*
 * 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 org.apache.commons.io;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Stack;

/**
 * General filename and filepath manipulation utilities.
 * <p>
 * When dealing with filenames you can hit problems when moving from a Windows
 * based development machine to a Unix based production machine.
 * This class aims to help avoid those problems.
 * <p>
 * <b>NOTE</b>: You may be able to avoid using this class entirely simply by
 * using JDK {@link java.io.File File} objects and the two argument constructor
 * {@link java.io.File#File(java.io.File, java.lang.String) File(File,String)}.
 * <p>
 * Most methods on this class are designed to work the same on both Unix and Windows.
 * Those that don't include 'System', 'Unix' or 'Windows' in their name.
 * <p>
 * Most methods recognise both separators (forward and back), and both
 * sets of prefixes. See the javadoc of each method for details.
 * <p>
 * This class defines six components within a filename
 * (example C:\dev\project\file.txt):
 * <ul>
 * <li>the prefix - C:\</li>
 * <li>the path - dev\project\</li>
 * <li>the full path - C:\dev\project\</li>
 * <li>the name - file.txt</li>
 * <li>the base name - file</li>
 * <li>the extension - txt</li>
 * </ul>
 * Note that this class works best if directory filenames end with a separator.
 * If you omit the last separator, it is impossible to determine if the filename
 * corresponds to a file or a directory. As a result, we have chosen to say
 * it corresponds to a file.
 * <p>
 * This class only supports Unix and Windows style names.
 * Prefixes are matched as follows:
 * <pre>
 * Windows:
 * a\b\c.txt           --> ""          --> relative
 * \a\b\c.txt          --> "\"         --> current drive absolute
 * C:a\b\c.txt         --> "C:"        --> drive relative
 * C:\a\b\c.txt        --> "C:\"       --> absolute
 * \\server\a\b\c.txt  --> "\\server\" --> UNC
 *
 * Unix:
 * a/b/c.txt           --> ""          --> relative
 * /a/b/c.txt          --> "/"         --> absolute
 * ~/a/b/c.txt         --> "~/"        --> current user
 * ~                   --> "~/"        --> current user (slash added)
 * ~user/a/b/c.txt     --> "~user/"    --> named user
 * ~user               --> "~user/"    --> named user (slash added)
 * </pre>
 * Both prefix styles are matched always, irrespective of the machine that you are
 * currently running on.
 * <p>
 * Origin of code: Excalibur, Alexandria, Tomcat, Commons-Utils.
 *
 * @author <a href="mailto:burton@relativity.yi.org">Kevin A. Burton</A>
 * @author <a href="mailto:sanders@apache.org">Scott Sanders</a>
 * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
 * @author <a href="mailto:Christoph.Reck@dlr.de">Christoph.Reck</a>
 * @author <a href="mailto:peter@apache.org">Peter Donald</a>
 * @author <a href="mailto:jefft@apache.org">Jeff Turner</a>
 * @author Matthew Hawthorne
 * @author Martin Cooper
 * @author <a href="mailto:jeremias@apache.org">Jeremias Maerki</a>
 * @author Stephen Colebourne
 * @version $Id: FilenameUtils.java 289999 2005-09-18 23:12:45Z scolebourne $
 * @since Commons IO 1.1
 */
public class FilenameUtils {

    /**
     * The extension separator character.
     */
    private static final char EXTENSION_SEPARATOR = '.';

    /**
     * The Unix separator character.
     */
    private static final char UNIX_SEPARATOR = '/';

    /**
     * The Windows separator character.
     */
    private static final char WINDOWS_SEPARATOR = '\\';

    /**
     * The system separator character.
     */
    private static final char SYSTEM_SEPARATOR = File.separatorChar;

    /**
     * The separator character that is the opposite of the system separator.
     */
    private static final char OTHER_SEPARATOR;
    static {
        if (SYSTEM_SEPARATOR == WINDOWS_SEPARATOR) {
            OTHER_SEPARATOR = UNIX_SEPARATOR;
        } else {
            OTHER_SEPARATOR = WINDOWS_SEPARATOR;
        }
    }

    /**
     * Instances should NOT be constructed in standard programming.
     */
    public FilenameUtils() {
        super();
    }

    //-----------------------------------------------------------------------
    /**
     * Checks if the character is a separator.
     * 
     * @param ch  the character to check
     * @return true if it is a separator character
     */
    private static boolean isSeparator(char ch) {
        return (ch == UNIX_SEPARATOR) || (ch == WINDOWS_SEPARATOR);
    }

    //-----------------------------------------------------------------------
    /**
     * Normalizes a path, removing double and single dot path steps.
     * <p>
     * This method normalizes a path to a standard format.
     * The input may contain separators in either Unix or Windows format.
     * The output will contain separators in the format of the system.
     * <p>
     * A trailing slash will be retained.
     * A double slash will be merged to a single slash (but UNC names are handled).
     * A single dot path segment will be removed.
     * A double dot will cause that path segment and the one before to be removed.
     * If the double dot has no parent path segment to work with, <code>null</code>
     * is returned.
     * <p>
     * The output will be the same on both Unix and Windows except
     * for the separator character.
     * <pre>
     * /foo//               -->   /foo/
     * /foo/./              -->   /foo/
     * /foo/../bar          -->   /bar
     * /foo/../bar/         -->   /bar/
     * /foo/../bar/../baz   -->   /baz
     * //foo//./bar         -->   /foo/bar
     * /../                 -->   null
     * ../foo               -->   null
     * foo/bar/..           -->   foo/
     * foo/../../bar        -->   null
     * foo/../bar           -->   bar
     * //server/foo/../bar  -->   //server/bar
     * //server/../bar      -->   null
     * C:\foo\..\bar        -->   C:\bar
     * C:\..\bar            -->   null
     * ~/foo/../bar/        -->   ~/bar/
     * ~/../bar             -->   null
     * </pre>
     * (Note the file separator returned will be correct for Windows/Unix)
     *
     * @param filename  the filename to normalize, null returns null
     * @return the normalized filename, or null if invalid
     */
    public static String normalize(String filename) {
        return doNormalize(filename, true);
    }

    //-----------------------------------------------------------------------
    /**
     * Normalizes a path, removing double and single dot path steps,
     * and removing any final directory separator.
     * <p>
     * This method normalizes a path to a standard format.
     * The input may contain separators in either Unix or Windows format.
     * The output will contain separators in the format of the system.
     * <p>
     * A trailing slash will be removed.
     * A double slash will be merged to a single slash (but UNC names are handled).
     * A single dot path segment will be removed.
     * A double dot will cause that path segment and the one before to be removed.
     * If the double dot has no parent path segment to work with, <code>null</code>
     * is returned.
     * <p>
     * The output will be the same on both Unix and Windows except
     * for the separator character.
     * <pre>
     * /foo//               -->   /foo
     * /foo/./              -->   /foo
     * /foo/../bar          -->   /bar
     * /foo/../bar/         -->   /bar
     * /foo/../bar/../baz   -->   /baz
     * //foo//./bar         -->   /foo/bar
     * /../                 -->   null
     * ../foo               -->   null
     * foo/bar/..           -->   foo
     * foo/../../bar        -->   null
     * foo/../bar           -->   bar
     * //server/foo/../bar  -->   //server/bar
     * //server/../bar      -->   null
     * C:\foo\..\bar        -->   C:\bar
     * C:\..\bar            -->   null
     * ~/foo/../bar/        -->   ~/bar
     * ~/../bar             -->   null
     * </pre>
     * (Note the file separator returned will be correct for Windows/Unix)
     *
     * @param filename  the filename to normalize, null returns null
     * @return the normalized filename, or null if invalid
     */
    public static String normalizeNoEndSeparator(String filename) {
        return doNormalize(filename, false);
    }

    /**
     * Internal method to perform the normalization.
     *
     * @param filename  the filename
     * @param keepSeparator  true to keep the final separator
     * @return the normalized filename
     */
    private static String doNormalize(String filename, boolean keepSeparator) {
        if (filename == null) {
            return null;
        }
        int size = filename.length();
        if (size == 0) {
            return filename;
        }
        int prefix = getPrefixLength(filename);
        if (prefix < 0) {
            return null;
        }
        
        char[] array = new char[size + 2];  // +1 for possible extra slash, +2 for arraycopy
        filename.getChars(0, filename.length(), array, 0);
        
        // fix separators throughout
        for (int i = 0; i < array.length; i++) {
            if (array[i] == OTHER_SEPARATOR) {
                array[i] = SYSTEM_SEPARATOR;
            }
        }
        
        // add extra separator on the end to simplify code below
        boolean lastIsDirectory = true;
        if (array[size - 1] != SYSTEM_SEPARATOR) {
            array[size++] = SYSTEM_SEPARATOR;
            lastIsDirectory = false;
        }
        
        // adjoining slashes
        for (int i = prefix + 1; i < size; i++) {
            if (array[i] == SYSTEM_SEPARATOR && array[i - 1] == SYSTEM_SEPARATOR) {
                System.arraycopy(array, i, array, i - 1, size - i);
                size--;
                i--;
            }
        }
        
        // dot slash
        for (int i = prefix + 1; i < size; i++) {
            if (array[i] == SYSTEM_SEPARATOR && array[i - 1] == '.' &&
                    (i == prefix + 1 || array[i - 2] == SYSTEM_SEPARATOR)) {
                if (i == size - 1) {
                    lastIsDirectory = true;
                }
                System.arraycopy(array, i + 1, array, i - 1, size - i);
                size -=2;
                i--;
            }
        }
        
        // double dot slash
        outer:
        for (int i = prefix + 2; i < size; i++) {
            if (array[i] == SYSTEM_SEPARATOR && array[i - 1] == '.' && array[i - 2] == '.' &&
                    (i == prefix + 2 || array[i - 3] == SYSTEM_SEPARATOR)) {
                if (i == prefix + 2) {
                    return null;
                }
                if (i == size - 1) {
                    lastIsDirectory = true;
                }
                int j;
                for (j = i - 4 ; j >= prefix; j--) {
                    if (array[j] == SYSTEM_SEPARATOR) {
                        // remove b/../ from a/b/../c
                        System.arraycopy(array, i + 1, array, j + 1, size - i);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中日韩av电影| 精品视频在线免费| 26uuu国产一区二区三区| 免费看精品久久片| 精品日韩一区二区三区| 国产精品羞羞答答xxdd | 欧美在线你懂得| 亚洲成av人影院在线观看网| 欧美福利视频一区| 国内精品伊人久久久久av一坑| 久久综合九色综合欧美亚洲| 国产福利精品导航| 综合自拍亚洲综合图不卡区| 欧美日韩日日骚| 精品一区二区三区在线播放视频| 精品国产麻豆免费人成网站| 丰满少妇在线播放bd日韩电影| 亚洲精品综合在线| 欧美老女人在线| 国产精品一品二品| 亚洲综合一区在线| 精品国产1区二区| 91片黄在线观看| 美女看a上一区| 1024成人网| 欧美电影免费观看完整版| 福利视频网站一区二区三区| 亚洲午夜精品网| 欧美国产日韩亚洲一区| 欧美日韩极品在线观看一区| 99视频精品免费视频| 亚洲成人自拍网| 国产欧美日韩视频一区二区| 欧美日韩国产精选| 成人av免费观看| 日日夜夜一区二区| 国产精品久线在线观看| 91精品国产综合久久久久久| 99久久精品一区| 九九久久精品视频| 亚洲国产精品天堂| 国产精品久久久久久久久晋中| 7777精品伊人久久久大香线蕉的 | 暴力调教一区二区三区| 秋霞影院一区二区| 亚洲黄色尤物视频| 国产欧美日韩精品a在线观看| 678五月天丁香亚洲综合网| 成人av在线资源网站| 日韩成人伦理电影在线观看| 亚洲免费毛片网站| 国产欧美久久久精品影院| 欧美一区二区三区免费大片| 在线观看日韩精品| 成人精品视频.| 国产呦精品一区二区三区网站| 亚洲成av人片一区二区梦乃| 亚洲天天做日日做天天谢日日欢| 久久综合九色欧美综合狠狠| 91精品久久久久久久99蜜桃| 欧美日韩第一区日日骚| 欧美亚洲自拍偷拍| 在线视频你懂得一区二区三区| 成人综合日日夜夜| 成人免费毛片嘿嘿连载视频| 久久精品噜噜噜成人88aⅴ| 亚洲成人av电影在线| 亚洲一区国产视频| 亚洲国产cao| 亚洲一二三区不卡| 一区二区三区欧美亚洲| 亚洲狼人国产精品| 亚洲黄色免费电影| 亚洲第一精品在线| 午夜电影网一区| 日本美女视频一区二区| 奇米精品一区二区三区在线观看| 午夜视频在线观看一区二区三区| 一区二区三区波多野结衣在线观看 | 一区二区在线观看不卡| 亚洲视频一区在线| 亚洲一区在线电影| 五月天欧美精品| 日韩精品电影在线| 国产一区在线观看视频| 国产乱对白刺激视频不卡| 国产老肥熟一区二区三区| 国产一区二区三区高清播放| 国产·精品毛片| av电影在线观看一区| 日本久久一区二区三区| 欧美日韩激情一区二区| 国产精品欧美一级免费| 亚洲天堂精品在线观看| 午夜精品123| 国产中文一区二区三区| 成人av小说网| 欧美视频精品在线| 精品成人一区二区三区| 国产精品视频麻豆| 一区二区免费视频| 久久电影网站中文字幕| 成人中文字幕电影| 在线免费一区三区| 日韩一级成人av| 国产精品视频一二| 午夜精品一区二区三区免费视频| 久久精品久久精品| 91年精品国产| 日韩一级片网站| **欧美大码日韩| 精品综合久久久久久8888| 成av人片一区二区| 日韩欧美国产成人一区二区| 国产精品网站在线观看| 天天操天天干天天综合网| 国产精品一区二区无线| 欧美视频精品在线观看| 久久久久国色av免费看影院| 奇米综合一区二区三区精品视频| 国产精品小仙女| 欧美视频一区二区三区四区| 国产丝袜美腿一区二区三区| 亚洲综合免费观看高清在线观看| 国内精品写真在线观看| 欧美色综合网站| 国产精品久久毛片| 美女视频一区在线观看| 色综合久久精品| 国产欧美日韩亚州综合| 美腿丝袜亚洲一区| 欧美性做爰猛烈叫床潮| 国产精品日产欧美久久久久| 青青草精品视频| 欧美体内she精高潮| 国产精品国产三级国产普通话99 | 国产精品欧美久久久久无广告| 日韩国产在线观看一区| 91欧美一区二区| 欧美韩日一区二区三区四区| 日本va欧美va精品发布| 日本乱码高清不卡字幕| 综合激情成人伊人| 国产精品一区二区在线观看不卡| 欧美一卡二卡三卡四卡| 亚洲国产美国国产综合一区二区| voyeur盗摄精品| 国产欧美日韩精品a在线观看| 久久国产免费看| 日韩亚洲电影在线| 日本不卡视频在线| 欧美亚洲一区二区在线观看| 亚洲视频在线一区二区| eeuss国产一区二区三区| 国产视频一区在线播放| 国产一区二区美女诱惑| 日韩免费视频线观看| 水野朝阳av一区二区三区| 欧美日韩中字一区| 亚洲国产精品尤物yw在线观看| 色欲综合视频天天天| 亚洲精品国产无天堂网2021| 成人免费看的视频| 国产精品青草综合久久久久99| 粉嫩久久99精品久久久久久夜| 国产亚洲欧洲997久久综合| 国产精品1024久久| 欧美激情一区二区三区四区| 成人免费高清视频| 国产精品国产三级国产普通话蜜臀| 成人av在线看| 亚洲精品菠萝久久久久久久| 在线观看视频91| 图片区日韩欧美亚洲| 91精品国产入口| 国产在线不卡一区| 久久久久久久久伊人| 99精品视频在线观看| 一区二区三区欧美视频| 欧美日本免费一区二区三区| 日本强好片久久久久久aaa| 欧美sm极限捆绑bd| 国产91精品一区二区麻豆网站 | 欧美日韩一区三区四区| 视频一区在线视频| 久久综合色之久久综合| 99久久伊人精品| 午夜精品久久久久久久99樱桃| 日韩精品中午字幕| 国产91丝袜在线18| 亚洲香蕉伊在人在线观| 日韩一区二区三区在线| 国产91高潮流白浆在线麻豆| 一区二区三区中文字幕电影| 日韩欧美在线一区二区三区| 国产jizzjizz一区二区| 亚洲观看高清完整版在线观看| 精品日韩99亚洲| 色婷婷综合久久久中文一区二区| 天天影视色香欲综合网老头|