- 浏览: 103165 次
- 性别:
- 来自: 杭州
文章分类
最新评论
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 7001:改变的入参的值。错误的代码: public static ... -
容易搞混的问题
2011-05-07 14:53 7821:switch语法的运用 public static vo ... -
自写的连接池-生产者消费者
2010-10-25 11:38 793public class DBConnectionPool ... -
简陋线程池1
2010-10-12 14:46 798package pool; import java.ut ... -
内部类和外部类的关系思考
2010-08-19 10:34 850编译期报错的代码 : import ipad.IpadHtt ... -
FieldReader
2010-08-14 10:35 755package utils; import java.i ... -
sax解析
2010-07-27 17:40 648package mySaxDo; import java ... -
dom树打印
2010-07-22 17:00 1079package demo; import org.apach ... -
socket编程
2010-07-22 09:09 1530服务器端: package server; ... -
单例模式和 properties
2010-07-13 17:04 966import java.io.File; import ja ... -
equals和==小测试
2010-07-01 09:44 808package testSingle; import o ... -
对String对象的操作
2010-06-30 13:50 744/** 写一个方法,实现字符串的反转,如:输入abc,输出c ... -
包装类Integer
2010-06-28 15:02 841package othertest; import or ... -
计算出出现次数最多的字母和该字母出现的次数
2010-06-28 10:13 1054方法一: package testString; im ... -
java调用plsql
2010-06-15 20:48 3490package test; import java.sql. ... -
xml解析(转)
2010-06-15 20:42 725JAVA 2009-11-09 10:22:33 阅读10 ... -
ObjectInputStream流 持久化
2010-06-15 20:39 987ObjectInputStream流 持久化 vo类: ...
相关推荐
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 ...
npm install fs-directory-stream 如果您的目录包含大量目录/文件,并且您不想一次将它们全部读入ram,则很有用。 用法 var createDirectoryStream = require ( 'fs-directory-stream' ) createDirectoryStream ( ...
deepstream-app: error while loading shared libraries: libnvinfer.so.7: cannot open shared object file: No such file or directory
可以选择 Directory 或者 Select Origin > Directory,添加一个目录,并填写 Files Directory 和 File Name Pattern 等属性。 7. 文件目录和修改属性 在添加文件目录时,需要填写 Files Directory 和 File Name ...
# Move into the new directory cd livestream-gatsby-themes/ # Install dependencies yarn # Start the site on http://localhost:8000 yarn workspace site develop 如果这是您第一次使用Yarn工作区, 。 链接和...
if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO) { AVCodecContext *codecCtx = stream->codec; AVCodec *codec = avcodec_find_decoder(codecCtx->codec_id); if (!codec || avcodec_open2(codecCtx, ...
ICS - Internet Component Suite - V8 - Delphi 7 to RAD Studio 10 Seattle ======================================================================= ...Rename the old ICS directory and unzip to...
-- 设置最大上传文件大小 --> </interceptor-ref> <result name="success">/success.jsp</result> <result name="input">/upload.jsp</result> </action> </package> ``` 当文件成功上传后,我们通常会将其移动...
{****************************************************************************** * * * PROJECT : EOS Digital Software Development Kit EDSDK * * NAME : EDSDKApi.pas * * * * Description: This is the ...
.filter(part -> part.getName().equals("file")) // 检查是否为上传文件部分 .collect(Collectors.toList()); if (parts.isEmpty()) { // 处理错误,如没有文件上传 } for (Part part : parts) { String ...
-- Spring WebSocket Starter 为WebSocket提供支持,虽然这里不直接使用,但为了完整的示例添加 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-websocket...
SOUND_EFFECTS_DIRECTORY-存储声音效果的目录 色相灯 HUE_LIGHT_IDS-灯泡ID的逗号分隔列表HUE_USERNAME-色相桥的用户名HUE_BRIDGE_IP-色相桥的本地IP 椒盐脆饼 TWITCH_ID-Twitch用户的ID OBS OBS_ADDRESS-OBS Web套...
-- 1MB --> <param name="allowedTypes">image/jpeg,image/png,application/pdf</param> </interceptor-ref> <result name="success">/success.jsp</result> <result name="input">/upload.jsp</result> ...
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
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/...
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) : 聚合器-...
-- 设置最大上传大小 --> </interceptor-ref> <result name="success">/success.jsp</result> </action> ``` #### 1.3 HTML表单 创建一个HTML表单,使用`enctype="multipart/form-data"`指定多部分表单数据,...
var filePath = Path.Combine(Directory.GetCurrentDirectory(), "uploads", file.FileName); using (var stream = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(stream); } // ...