// : c12:DirList.java
// Displays directory listing using regular expressions.
// {Args: "D.*\.java"}
// From 'Thinking in Java, 3rd ed.' (c) Bruce Eckel 2002
// www.BruceEckel.com. See copyright notice in CopyRight.txt.
import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.regex.Pattern;
public class DirList {
public static void main(String[] args) {
File path = new File(".");
String[] list;
if (args.length == 0)
list = path.list();
else
list = path.list(new DirFilter(args[0]));
Arrays.sort(list, new AlphabeticComparator());
for (int i = 0; i < list.length; i++)
System.out.println(list[i]);
}
}
class DirFilter implements FilenameFilter {
private Pattern pattern;
public DirFilter(String regex) {
pattern = Pattern.compile(regex);
}
public boolean accept(File dir, String name) {
// Strip path information, search for regex:
return pattern.matcher(new File(name).getName()).matches();
}
} ///:~
class AlphabeticComparator implements Comparator {
public int compare(Object o1, Object o2) {
String s1 = (String) o1;
String s2 = (String) o2;
return s1.toLowerCase().compareTo(s2.toLowerCase());
}
} ///:~
分享到:
相关推荐
欢迎使用nanoFramework System.Text.RegularExpressions存储库!建置状态成分建置状态NuGet软件包System.Text.RegularExpressions System.Text.RegularExpressions(预览) 重要提示:此正则表达式解析器将满足您的...
### 移动交互式投影显示使用基于投影仪的跟踪技术 #### 摘要与背景 本文介绍了一种创新的技术,即使用基于投影仪的位置跟踪技术来实现移动表面的交互式投影显示。传统上,视频投影仪主要用于在相对投影仪几何关系...
Describing the use of displays in microcontroller based projects, the author makes extensive use of real-world, tested projects. The complete details of each project are given, including the full ...
标题"Neon Glow Displays Vol_2_9.5.rar"表明这可能是一个关于Unity3D霓虹灯效果的资源包,版本号为9.5,可能包含升级或改进的霓虹灯显示效果。".rar"文件格式是常见的压缩文件格式,用于存储多个文件在一个包里。 ...
Streams, files, and regular expressions XML Networking Database programming facilities JNDI/LDAP directory integration Internationalization Advanced Swing techniques JavaBeans components Web services ...
一款运行于Unity平台的插件 霓虹灯光展示效果资源包Neon Glow Displays Vol_2 1.0 所支持的Unity版本:5.3.4 及以上版本 Amazing Neon display pack! This is a great pack include materials, prefabs, FX sc ripts ...
i = System.Text.RegularExpressions.Regex.Matches(TextBox1.Text, "\r\n").Count '用一个数组来接收textbox1各行的信息 Shuzu = New String(i - 1) {} For x As Integer = 0 To i - 1 Shuzu(x) = TextBox1....
新版完整标准 IEC 62906-5-5-2022 Laser displays - Part 5-5_ Optical measuring methods of raster-scanning retina direct projection laser displa.pdf
An introduction to using Perl-style regular expressions for search/replace Perl regex tutorial: non-greedy regular expressions Have you ever built a complex Perl-style regular expression, only to find...
### 计算机图形学中的边缘过滤技术 #### 引言 在计算机图形学领域,尤其是在处理基于栅格(像素网格)的图像时,如何绘制平滑的线条和边缘一直是一个重要的研究课题。传统的简单线描算法往往会产生“锯齿状”(即...
a program which reads XYL information defining points and lines in 2D and displays an image using OpenGL
Right clicking on each marker in the Markers toolbar displays a context menu, and allows you to enable or disable each marker, search for each marker, or change the match condition (case sensitivity, ...
With modern Ultra-HD displays ("4K displays") at sizes of 28" or smaller, this game has changed forever. Simply because no human being is sharp-sighted enough to comfortably read text at the size of a...
《Unity中的霓虹光效展示:Neon Glow Displays Vol_2 v1.0》 Unity,作为一款全球领先的实时3D内容创作和运营平台,深受游戏开发者和视觉艺术家的青睐。其中,各种特效的实现是提升游戏视觉效果、增强用户体验的...
- **Listing Files** The `ls` command is used to list the files and directories in a directory. Options like `-l` for detailed listings and `-a` for showing hidden files enhance its functionality. - **...
regular file, directory, symbolic link, and block/char device inodes have different sizes). 5. Squashfs can use block sizes up to 32K (the default size is 32K). Using 32K blocks achieves greater ...
senors and displays based on structural colour; qualcomm P-INK, Morpho butterfly wing scales demonstrate highly selective vapour response
Allen Bradley PLC Programming using Factory IO - Emitters, Digital Displays, Integers Allen-Bradley PLC使用Factory IO 编程-发射器、数字显示器、积分器
"Screen Saver which Displays Pictures" 是这样一个简单的屏幕保护程序,它会在闲置时启动,并展示图片来活动屏幕。 这个5KB的小程序虽然体积小巧,但其背后涉及的技术原理却很丰富。首先,屏幕保护程序的运行依赖...