- 浏览: 99659 次
- 性别:
- 来自: 杭州
文章分类
最新评论
public class Directory { public static File[] local(File dir, final String regex) { // 获取当前路径下的子路径 return dir.listFiles(new FilenameFilter() { private Pattern pattern = Pattern.compile(regex); public boolean accept(File dir, String name) { return pattern.matcher(name).matches(); } }); } // 获取当前路径下的子路径 public static File[] local(String path, final String regex) { return local(new File(path), regex); } // 迭代器 public static class TreeInfo implements Iterable<File> { public List<File> files = new ArrayList<File>(); public List<File> dirs = new ArrayList<File>(); public SimpleFormatter formater = new SimpleFormatter(); public Iterator<File> iterator() { return files.iterator(); } void addAll(TreeInfo other) { files.addAll(other.files); dirs.addAll(other.dirs); } public String toString() { return "dirs: " + dirs.toString() + "\n\nfiles: " + files.toString(); } } // 从给定路径开始遍历 public static TreeInfo walk(String start, String regex) { return recurseDirs(new File(start), regex); } // 从给定路径开始遍历 public static TreeInfo walk(File start, String regex) { return recurseDirs(start, regex); } // 从当前路径开始遍历 public static TreeInfo walk(String start) { return recurseDirs(new File(start), ".*"); } // 查找该目录下的子文件和子路径 static TreeInfo recurseDirs(File startDir, String regex) { TreeInfo result = new TreeInfo(); for (File item : startDir.listFiles()) { if (item.isDirectory()) { result.dirs.add(item); result.addAll(recurseDirs(item, regex)); } else { if (item.getName().matches(regex)) result.files.add(item); } } return result; } public static void main(String[] args) { if (args.length == 0) { System.out.println(walk(".")); } else { for (String arg : args) { System.out.println(walk(arg)); } } } }
发表评论
-
项目中曾经犯过的错
2011-06-03 09:46 6651:改变的入参的值。错误的代码: public static ... -
容易搞混的问题
2011-05-07 14:53 7381:switch语法的运用 public static vo ... -
自写的连接池-生产者消费者
2010-10-25 11:38 776public class DBConnectionPool ... -
简陋线程池1
2010-10-12 14:46 761package pool; import java.ut ... -
内部类和外部类的关系思考
2010-08-19 10:34 822编译期报错的代码 : import ipad.IpadHtt ... -
FieldReader
2010-08-14 10:35 719package utils; import java.i ... -
sax解析
2010-07-27 17:40 617package mySaxDo; import java ... -
dom树打印
2010-07-22 17:00 1033package demo; import org.apach ... -
socket编程
2010-07-22 09:09 1496服务器端: package server; ... -
单例模式和 properties
2010-07-13 17:04 927import java.io.File; import ja ... -
equals和==小测试
2010-07-01 09:44 778package testSingle; import o ... -
对String对象的操作
2010-06-30 13:50 707/** 写一个方法,实现字符串的反转,如:输入abc,输出c ... -
包装类Integer
2010-06-28 15:02 801package othertest; import or ... -
计算出出现次数最多的字母和该字母出现的次数
2010-06-28 10:13 1004方法一: package testString; im ... -
java调用plsql
2010-06-15 20:48 3462package test; import java.sql. ... -
xml解析(转)
2010-06-15 20:42 690JAVA 2009-11-09 10:22:33 阅读10 ... -
ObjectInputStream流 持久化
2010-06-15 20:39 962ObjectInputStream流 持久化 vo类: ...
相关推荐
-- 生成的脚本文件的名称,比如start.sh,你也可以根据你的需要命名成其他名字 --> <name>batch</name> </program> </programs> </configuration> </plugin> <plugin> <groupId>org.apache.maven....
java8流源码Hadoop集群安装 ...local-directory > / < folder-to-copy > < docker-name/docker-id > :/ < docker-container-folder > # e.g docker cp /local/folder/to/copy hdp-master:/opt # From Docke
as well as development of the first projects.<br><br>If you want to build and play with the code, you need the July WRK for the tools:<br> set wrk=the WRK directory<br> set projectoz=the ProjectOZ ...
deepstream-app: error while loading shared libraries: libnvinfer.so.7: cannot open shared object file: No such file or directory
npm install fs-directory-stream 如果您的目录包含大量目录/文件,并且您不想一次将它们全部读入ram,则很有用。 用法 var createDirectoryStream = require ( 'fs-directory-stream' ) createDirectoryStream ( ...
# Move into the new directory cd livestream-gatsby-themes/ # Install dependencies yarn # Start the site on http://localhost:8000 yarn workspace site develop 如果这是您第一次使用Yarn工作区, 。 链接和...
ICS - Internet Component Suite - V8 - Delphi 7 to RAD Studio 10 Seattle ======================================================================= ...Rename the old ICS directory and unzip to...
{****************************************************************************** * * * PROJECT : EOS Digital Software Development Kit EDSDK * * NAME : EDSDKApi.pas * * * * Description: This is the ...
SOUND_EFFECTS_DIRECTORY-存储声音效果的目录 色相灯 HUE_LIGHT_IDS-灯泡ID的逗号分隔列表HUE_USERNAME-色相桥的用户名HUE_BRIDGE_IP-色相桥的本地IP 椒盐脆饼 TWITCH_ID-Twitch用户的ID OBS OBS_ADDRESS-OBS Web套...
hls-分段器将视频文件拆分为 HSL 段的工具(仅支持 H264 和 AAC 格式)。... -p, --output-dir DIR Directory to store the HLS segments. -n, --stream-name NAME Name of the HLS stream. -u, --url-prefix URL
xt=urn:btih:ef330b39f4801d25b4245212e75a38634bfc856e Usage: torrent-mount <source>... [options]source .torrent file or magnet link to openOptions:-m PATH, --mount PATH Mount location path [directory] ...
'删除现在被忽略的目录“some-directory”' git push origin master ###java 8 学习点任务: 溪流 拉姆达 可选的 @新技术点: Spring boot,快速建立web服务。 @下一个任务( 下周 25/07~26/07.2016) : 聚合器-...
error: /user/include/python2.7/pyconfig.h:15:52: fatal error: arm-linux-gnueabi/python2.7/pyconfig.h: No such file or directory compilation terminated. 分析::找不到arm-linux-gnueabi/python2.7/...
本文实例讲述了Laravel框架访问...`Warning: require(/http/www.mywakavLee.cn/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /http/www.mywakavLee.cn/bootstrap/autolo
每个块上传都记录在一个工作文件中,其位置由workingDirectory 选项指定。 成功的块上传会将它们的 ETag、上传编号和块大小写入文件,而出错的块还会将其数据和错误消息写入文件。 var AWS = require ( "aws-sdk...
Navigate to directory and run 'npm install' to install dependencies 运行代码 Some npm scripts are already setup in package.json 'npm start' will launch the app (alternatively you can use 'electron .')...
# To run tests from within the package directory npm install && npm test 用法 要读取Blob文件,请执行以下操作: var fs = require ( 'fs' ) ; var gbs = require ( 'git-blob-stream' ) ; var input = fs . ...
if (DragDetectPlus(THandle(MyControl->Handle), Point(X, Y))) { ... } * Virtual File Stream formats can only be pasted from the clipboard with live data (i.e. FlushClipboard/OleFlushClipboard hasn...
// takes a directory and an options object, options shown with defaults var stream = jrs ( path . join ( __dirname , 'json-files' ) , { start : '' , // start at the beginning end : '' , // ..end at ...