呵呵,来备份一个函数 关于 * 匹配文件名的东西(就是在一个文件夹下面找一类文件的东西)。有需要的也可以参考 一下

shclhs 2006-01-29 10:01:06
没有好好的写,只写了一个简单的,连参数验证都没加。需要的 自己加
public static void main(String[] args) {
String path = "c:\\temp";
File file = new File(path);
String[] files = file.list();
for (int i = 0; i < files.length; i++) {
if (isMatched("*.exe", files[i])) {
System.out.println(files[i]);
}
}
}

// a*b*c*d.txt
// *b.txt
// b*.txt
public static boolean isMatched(String arg1, String arg2) {
boolean result = false;
int position = 0;

String[] array = arg1.split("\\*");

for (int i = 0; i < array.length; i++) {
if (i == 0) {
if (arg2.indexOf(array[i], position) != 0) {
return result;
}

position = arg2.indexOf(array[i], position) + array[i].length();
} else if (i == array.length - 1) {
if (!arg2.endsWith(array[i])) {
return result;
}
} else {
if (arg2.indexOf(array[i], position) < position) {
return result;
}

position = arg2.indexOf(array[i], position) + array[i].length();
}
}

result = true;

return result;
}
...全文
87 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
shclhs 2006-02-19
  • 打赏
  • 举报
回复
http://www.koders.com/csharp/fidD30F7807F524113F3C15CC35DDD91C48D03F6FBE.aspx
http://www.codeproject.com/dotnet/Surrogate_Serialization.asp
shclhs 2006-02-12
  • 打赏
  • 举报
回复
good blog for dotnet
http://fredrik.nsquared2.com/default.aspx
shclhs 2006-02-12
  • 打赏
  • 举报
回复
http://channel9.msdn.com/wiki/default.aspx/SecurityWiki.HomePage
About DotNet security

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧