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

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

?? filesystemutils.java

?? j2me簡單實例,j2me教程加源碼,希望大家喜歡
?? JAVA
字號:
/*
 * Copyright 2005-2006 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.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * General File System utilities.
 * <p>
 * This class provides static utility methods for general file system
 * functions not provided via the JDK {@link java.io.File File} class.
 * <p>
 * The current functions provided are:
 * <ul>
 * <li>Get the free space on a drive
 * </ul>
 *
 * @author Frank W. Zammetti
 * @author Stephen Colebourne
 * @author Thomas Ledoux
 * @version $Id: FileSystemUtils.java 385680 2006-03-13 22:27:09Z scolebourne $
 * @since Commons IO 1.1
 */
public class FileSystemUtils {

    /** Singleton instance, used mainly for testing. */
    private static final FileSystemUtils INSTANCE = new FileSystemUtils();

    /** Operating system state flag for error. */
    private static final int INIT_PROBLEM = -1;
    /** Operating system state flag for neither Unix nor Windows. */
    private static final int OTHER = 0;
    /** Operating system state flag for Windows. */
    private static final int WINDOWS = 1;
    /** Operating system state flag for Unix. */
    private static final int UNIX = 2;

    /** The operating system flag. */
    private static final int OS;
    static {
        int os = OTHER;
        try {
            String osName = System.getProperty("os.name");
            if (osName == null) {
                throw new IOException("os.name not found");
            }
            osName = osName.toLowerCase();
            // match
            if (osName.indexOf("windows") != -1) {
                os = WINDOWS;
            } else if (osName.indexOf("linux") != -1 ||
                osName.indexOf("sun os") != -1 ||
                osName.indexOf("sunos") != -1 ||
                osName.indexOf("solaris") != -1 ||
                osName.indexOf("mpe/ix") != -1 ||
                osName.indexOf("hp-ux") != -1 ||
                osName.indexOf("aix") != -1 ||
                osName.indexOf("freebsd") != -1 ||
                osName.indexOf("irix") != -1 ||
                osName.indexOf("digital unix") != -1 ||
                osName.indexOf("unix") != -1 ||
                osName.indexOf("mac os x") != -1) {
                os = UNIX;
            } else {
                os = OTHER;
            }

        } catch (Exception ex) {
            os = INIT_PROBLEM;
        }
        OS = os;
    }

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

    //-----------------------------------------------------------------------
    /**
     * Returns the free space on a drive or volume by invoking
     * the command line.
     * This method does not normalize the result, and typically returns
     * bytes on Windows, 512 byte units on OS X and kilobytes on Unix.
     * <p>
     * See also {@link #freeSpaceKb(String)} for a better implementation
     * which normalizes to kilobytes.
     * <p>
     * Note that some OS's are NOT currently supported, including OS/390.
     * <pre>
     * FileSystemUtils.freeSpace("C:");       // Windows
     * FileSystemUtils.freeSpace("/volume");  // *nix
     * </pre>
     * The free space is calculated via the command line.
     * It uses 'dir /-c' on Windows and 'df' on *nix.
     *
     * @param path  the path to get free space for, not null, not empty on Unix
     * @return the amount of free drive space on the drive or volume
     * @throws IllegalArgumentException if the path is invalid
     * @throws IllegalStateException if an error occurred in initialisation
     * @throws IOException if an error occurs when finding the free space
     */
    public static long freeSpace(String path) throws IOException {
        return INSTANCE.freeSpaceOS(path, OS, false);
    }

    //-----------------------------------------------------------------------
    /**
     * Returns the free space on a drive or volume in kilobytes by invoking
     * the command line.
     * Note that some OS's are NOT currently supported, including OS/390.
     * <pre>
     * FileSystemUtils.freeSpaceKb("C:");       // Windows
     * FileSystemUtils.freeSpaceKb("/volume");  // *nix
     * </pre>
     * The free space is calculated via the command line.
     * It uses 'dir /-c' on Windows and 'df -k' on *nix.
     *
     * @param path  the path to get free space for, not null, not empty on Unix
     * @return the amount of free drive space on the drive or volume in kilobytes
     * @throws IllegalArgumentException if the path is invalid
     * @throws IllegalStateException if an error occurred in initialisation
     * @throws IOException if an error occurs when finding the free space
     * @since Commons IO 1.2
     */
    public static long freeSpaceKb(String path) throws IOException {
        return INSTANCE.freeSpaceOS(path, OS, true);
    }

    //-----------------------------------------------------------------------
    /**
     * Returns the free space on a drive or volume in a cross-platform manner.
     * Note that some OS's are NOT currently supported, including OS/390.
     * <pre>
     * FileSystemUtils.freeSpace("C:");  // Windows
     * FileSystemUtils.freeSpace("/volume");  // *nix
     * </pre>
     * The free space is calculated via the command line.
     * It uses 'dir /-c' on Windows and 'df' on *nix.
     *
     * @param path  the path to get free space for, not null, not empty on Unix
     * @param os  the operating system code
     * @param kb  whether to normalize to kilobytes
     * @return the amount of free drive space on the drive or volume
     * @throws IllegalArgumentException if the path is invalid
     * @throws IllegalStateException if an error occurred in initialisation
     * @throws IOException if an error occurs when finding the free space
     */
    long freeSpaceOS(String path, int os, boolean kb) throws IOException {
        if (path == null) {
            throw new IllegalArgumentException("Path must not be empty");
        }
        switch (os) {
            case WINDOWS:
                return (kb ? freeSpaceWindows(path) / 1024 : freeSpaceWindows(path));
            case UNIX:
                return freeSpaceUnix(path, kb);
            case OTHER:
                throw new IllegalStateException("Unsupported operating system");
            default:
                throw new IllegalStateException(
                  "Exception caught when determining operating system");
        }
    }

    /**
     * Find free space on the Windows platform using the 'dir' command.
     *
     * @param path  the path to get free space for, including the colon
     * @return the amount of free drive space on the drive
     * @throws IOException if an error occurs
     */
    long freeSpaceWindows(String path) throws IOException {
        path = FilenameUtils.normalize(path);
        if (path.length() > 2 && path.charAt(1) == ':') {
            path = path.substring(0, 2);  // seems to make it work
        }

        // build and run the 'dir' command
        String[] cmdAttrbs = new String[] {"cmd.exe", "/C", "dir /-c " + path};

        // read in the output of the command to an ArrayList
        BufferedReader in = null;
        String line = null;
        ArrayList lines = new ArrayList();
        try {
            in = openProcessStream(cmdAttrbs);
            line = in.readLine();
            while (line != null) {
                line = line.toLowerCase().trim();
                lines.add(line);
                line = in.readLine();
            }
        } finally {
            IOUtils.closeQuietly(in);
        }

        if (lines.size() == 0) {
            // unknown problem, throw exception
            throw new IOException(
                    "Command line 'dir /c' did not return any info " +
                    "for command '" + cmdAttrbs[2] + "'");
        }

        // now iterate over the lines we just read and find the LAST
        // non-empty line (the free space bytes should be in the last element
        // of the ArrayList anyway, but this will ensure it works even if it's
        // not, still assuming it is on the last non-blank line)
        long bytes = -1;
        int i = lines.size() - 1;
        int bytesStart = 0;
        int bytesEnd = 0;
        outerLoop: while (i > 0) {
            line = (String) lines.get(i);
            if (line.length() > 0) {
                // found it, so now read from the end of the line to find the
                // last numeric character on the line, then continue until we
                // find the first non-numeric character, and everything between
                // that and the last numeric character inclusive is our free
                // space bytes count
                int j = line.length() - 1;
                innerLoop1: while (j >= 0) {
                    char c = line.charAt(j);
                    if (Character.isDigit(c)) {
                      // found the last numeric character, this is the end of
                      // the free space bytes count
                      bytesEnd = j + 1;
                      break innerLoop1;
                    }
                    j--;
                }
                innerLoop2: while (j >= 0) {
                    char c = line.charAt(j);
                    if (!Character.isDigit(c) && c != ',' && c != '.') {
                      // found the next non-numeric character, this is the
                      // beginning of the free space bytes count
                      bytesStart = j + 1;
                      break innerLoop2;
                    }
                    j--;
                }
                break outerLoop;
            }
        }

        // remove commas and dots in the bytes count
        StringBuffer buf = new StringBuffer(line.substring(bytesStart, bytesEnd));
        for (int k = 0; k < buf.length(); k++) {
            if (buf.charAt(k) == ',' || buf.charAt(k) == '.') {
                buf.deleteCharAt(k--);
            }
        }
        bytes = Long.parseLong(buf.toString());
        return bytes;
    }

    /**
     * Find free space on the *nix platform using the 'df' command.
     *
     * @param path  the path to get free space for
     * @param kb  whether to normalize to kilobytes
     * @return the amount of free drive space on the volume
     * @throws IOException if an error occurs
     */
    long freeSpaceUnix(String path, boolean kb) throws IOException {
        if (path.length() == 0) {
            throw new IllegalArgumentException("Path must not be empty");
        }
        path = FilenameUtils.normalize(path);

        // build and run the 'dir' command
        String[] cmdAttribs = 
            (kb ? new String[] {"df", "-k", path} : new String[] {"df", path});

        // read the output from the command until we come to the second line
        long bytes = -1;
        BufferedReader in = null;
        try {
            in = openProcessStream(cmdAttribs);
            String line1 = in.readLine(); // header line (ignore it)
            String line2 = in.readLine(); // the line we're interested in
            String line3 = in.readLine(); // possibly interesting line
            if (line2 == null) {
                // unknown problem, throw exception
                throw new IOException(
                        "Command line 'df' did not return info as expected " +
                        "for path '" + path +
                        "'- response on first line was '" + line1 + "'");
            }
            line2 = line2.trim();

            // Now, we tokenize the string. The fourth element is what we want.
            StringTokenizer tok = new StringTokenizer(line2, " ");
            if (tok.countTokens() < 4) {
                // could be long Filesystem, thus data on third line
                if (tok.countTokens() == 1 && line3 != null) {
                    line3 = line3.trim();
                    tok = new StringTokenizer(line3, " ");
                } else {
                    throw new IOException(
                            "Command line 'df' did not return data as expected " +
                            "for path '" + path + "'- check path is valid");
                }
            } else {
                tok.nextToken(); // Ignore Filesystem
            }
            tok.nextToken(); // Ignore 1K-blocks
            tok.nextToken(); // Ignore Used
            String freeSpace = tok.nextToken();
            try {
                bytes = Long.parseLong(freeSpace);
            } catch (NumberFormatException ex) {
                throw new IOException(
                        "Command line 'df' did not return numeric data as expected " +
                        "for path '" + path + "'- check path is valid");
            }

        } finally {
            IOUtils.closeQuietly(in);
        }

        if (bytes < 0) {
            throw new IOException(
                    "Command line 'df' did not find free space in response " +
                    "for path '" + path + "'- check path is valid");
        }
        return bytes;
    }

    /**
     * Opens the stream to be operating system.
     *
     * @param params  the command parameters
     * @return a reader
     * @throws IOException if an error occurs
     */
    BufferedReader openProcessStream(String[] params) throws IOException {
        Process proc = Runtime.getRuntime().exec(params);
        return new BufferedReader(
            new InputStreamReader(proc.getInputStream()));
    }

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久99热99| 天天色天天操综合| 亚洲欧美激情小说另类| 日本午夜精品一区二区三区电影| 激情国产一区二区| 欧美日韩精品是欧美日韩精品| 久久久久久久久岛国免费| 一个色在线综合| 丁香婷婷深情五月亚洲| 日韩限制级电影在线观看| 亚洲婷婷综合色高清在线| 久久成人免费电影| 7777精品伊人久久久大香线蕉超级流畅 | 久久天天做天天爱综合色| 亚洲精品一二三| 成人永久免费视频| 欧美一区二区三区视频在线| 亚洲综合在线观看视频| 国产99久久久国产精品| 久久综合久久综合亚洲| 免费高清视频精品| 欧美亚洲国产一卡| 亚洲丝袜另类动漫二区| 成人午夜碰碰视频| 亚洲国产成人在线| 久久成人麻豆午夜电影| 欧美一级夜夜爽| 图片区小说区国产精品视频| 色综合久久综合中文综合网| 国产精品久久久久久久久搜平片| 国产老女人精品毛片久久| 精品国产91久久久久久久妲己| 天天综合天天综合色| 在线观看日韩电影| 亚洲尤物视频在线| 欧美色图12p| 午夜精品久久久| 欧美吞精做爰啪啪高潮| 手机精品视频在线观看| 欧美福利电影网| 婷婷成人激情在线网| 8x福利精品第一导航| 日韩高清欧美激情| 日韩精品一区二区三区老鸭窝| 久久精品国产精品亚洲红杏| 精品嫩草影院久久| 国产成人精品1024| 亚洲视频香蕉人妖| 欧美视频精品在线| 视频一区二区欧美| 日韩欧美一级精品久久| 国产乱妇无码大片在线观看| 国产网红主播福利一区二区| 成人激情校园春色| 亚洲一卡二卡三卡四卡五卡| 宅男在线国产精品| 国产乱子轮精品视频| 国产精品青草久久| 欧美在线你懂得| 日本欧美加勒比视频| 欧美一级久久久| 国产美女视频一区| 综合中文字幕亚洲| 6080国产精品一区二区| 国产精品自拍av| 亚洲另类色综合网站| 91精品国产综合久久久久久漫画| 狠狠色狠狠色合久久伊人| 国产精品视频一二三| 欧美日韩一区久久| 激情小说亚洲一区| 亚洲精品亚洲人成人网| 日韩亚洲欧美在线| 97精品久久久午夜一区二区三区 | 首页亚洲欧美制服丝腿| 国产亚洲女人久久久久毛片| 91日韩精品一区| 久久成人麻豆午夜电影| 亚洲色图在线播放| 精品国产乱码久久久久久1区2区| 成人av免费在线观看| 蜜桃视频在线一区| 亚洲精品你懂的| 国产日产欧美一区二区三区| 欧洲精品一区二区三区在线观看| 国产一区二区三区| 亚洲国产成人av网| 国产精品久久久一本精品| 日韩欧美综合在线| 欧美四级电影在线观看| 成人禁用看黄a在线| 日韩电影在线看| 亚洲天堂2016| 日本一区二区三区高清不卡 | 精品国产乱码91久久久久久网站| 成人av手机在线观看| 久久精品国产亚洲aⅴ| 亚洲国产人成综合网站| 国产精品欧美经典| 久久久久9999亚洲精品| 日韩欧美亚洲一区二区| 欧美美女直播网站| 91成人在线观看喷潮| 9色porny自拍视频一区二区| 国产精品综合在线视频| 麻豆精品一区二区| 日本女人一区二区三区| 亚洲成人动漫一区| 一区二区视频免费在线观看| 国产女同互慰高潮91漫画| 久久尤物电影视频在线观看| 日韩午夜在线影院| 日韩免费观看高清完整版| 91精品国产91综合久久蜜臀| 欧美色视频一区| 欧美日韩国产a| 欧美丝袜第三区| 欧美自拍丝袜亚洲| 在线观看视频欧美| 欧美性大战久久久久久久| 欧美日韩一区国产| 91精品国产色综合久久| 欧美一级电影网站| 久久久久久久综合日本| 国产日韩欧美在线一区| 国产精品女人毛片| 亚洲激情一二三区| 亚洲国产aⅴ天堂久久| 日本亚洲电影天堂| 国产麻豆日韩欧美久久| 国产成人小视频| 色天使久久综合网天天| 欧美日韩国产不卡| 精品女同一区二区| 中文字幕国产一区二区| 亚洲人成网站精品片在线观看 | 色又黄又爽网站www久久| 一本大道久久a久久精二百| 欧美中文字幕久久| 91麻豆精品国产91久久久久| 欧美第一区第二区| 欧美激情在线免费观看| 亚洲欧美电影院| 日韩国产精品久久久久久亚洲| 蜜臀精品一区二区三区在线观看| 国产精品一区二区三区网站| 91日韩在线专区| 宅男在线国产精品| 欧美高清在线精品一区| 亚洲午夜久久久久久久久电影院| 免费成人av在线播放| 国产98色在线|日韩| 欧美日韩一区视频| 国产亚洲欧洲997久久综合 | 久久久久国产免费免费| 亚洲乱码国产乱码精品精的特点 | 91麻豆精品国产综合久久久久久| 精品国产sm最大网站免费看| 亚洲色图视频网| 久久99精品国产麻豆不卡| 91小视频免费观看| xnxx国产精品| 午夜一区二区三区视频| 国产一区二区福利视频| 欧美主播一区二区三区| 国产精品污www在线观看| 亚洲电影在线播放| 成人爽a毛片一区二区免费| 91精品国产色综合久久久蜜香臀| 成人欧美一区二区三区黑人麻豆 | 懂色av一区二区三区免费看| 69堂国产成人免费视频| 亚洲人午夜精品天堂一二香蕉| 激情文学综合插| 884aa四虎影成人精品一区| 亚洲免费在线播放| 丁香另类激情小说| 亚洲精品在线免费观看视频| 亚洲国产精品久久人人爱| 成人激情免费网站| 精品成人在线观看| 日本免费在线视频不卡一不卡二| 91激情在线视频| 国产精品久久久久天堂| 久久99精品久久久久久| 欧美日韩一级大片网址| 日韩一区二区三区观看| 午夜精品久久一牛影视| 高清久久久久久| 国产亚洲精品资源在线26u| 亚洲一区二区三区免费视频| 国产不卡高清在线观看视频| 精品处破学生在线二十三| 亚洲丶国产丶欧美一区二区三区| 国产成人免费视频网站| 日韩欧美一级特黄在线播放| 亚洲高清中文字幕| 91性感美女视频| 日韩精品一区二区三区swag| 精一区二区三区|