FileUtil.java
资源名称:shihua.rar [点击查看]
上传用户:zghglow
上传日期:2022-08-09
资源大小:27227k
文件大小:1k
源码类别:
WEB源码(ASP,PHP,...)
开发平台:
JavaScript
- package com.chinacannel.common;
- import java.io.*;
- import java.util.*;
- public class FileUtil {
- private File file;
- public FileUtil(){
- }
- public FileUtil(String baseDir) {
- this.file = new File(baseDir);
- }
- public List getFolders() {
- return this.getFolders(file);
- }
- public List getFolders(File dir) {
- List folders = new ArrayList();
- File[] fileList = dir.listFiles();
- if(fileList!=null){
- for (int i = 0; i < fileList.length; i++) {
- File f = fileList[i];
- if (f.isDirectory()) {
- MyFolder folder = new MyFolder();
- folder.setFolder(f);
- folders.add(folder);
- }
- }
- }
- return folders;
- }
- public List getFiles() {
- return this.getFiles(file);
- }
- public List getFiles(File dir) {
- List files = new ArrayList();
- File[] fileList = dir.listFiles();
- if(fileList!=null){
- for (int i = 0; i < fileList.length; i++) {
- File f = fileList[i];
- if (f.isFile()) {
- MyFile file = new MyFile();
- file.setFile(f);
- files.add(file);
- }
- }
- }
- return files;
- }
- public void deleteFile() {
- file.delete();
- }
- }