filemanager.java

来自「服务器端源文件:btServer-20050819.zip」· Java 代码 · 共 67 行

JAVA
67
字号
/*  * Description : File manager to update directory and file listing. *  * Notes :  *  * LICENSE : This code is licensed under GPL. (See http://www.gnu.org/copyleft/gpl.html) *  * fileManager.java @version 1.0 * Created on May 3, 2005 *  */package btServer;import java.io.File;public class fileManager {        private String fileList[];    private String filePath;        private int fileCount;    public fileManager() {                      // Get directory listing                filePath = System.getProperty("user.dir");        filePath = filePath.concat(File.separator);        filePath = filePath.concat("files");          File temp = new File(filePath);        fileList = temp.list();                fileCount = 0;                for (int i = 0; i < fileList.length; i++){            temp = new File(filePath + File.separator + fileList[i]);                        if (temp.isFile()) {                fileList[fileCount] = fileList[i];                fileCount++;                            }        }                                 }           public String[] getFileList(){        return fileList;           }    public String getFilePath() {        return filePath;    }        public int getFileCount(){        return fileCount;    }        /*     * Testing only     */    public static void main(String[] args) {        fileManager fm1 = new fileManager();                                       System.out.println(fm1.getFileCount());                for (int i = 0; i < fm1.getFileCount() ;i++ ){            System.out.println(fm1.getFileList()[i]);        }             }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?