- 浏览: 1294813 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (471)
- Database (29)
- Java (47)
- Frameworks (9)
- JavaScript (30)
- Others (27)
- ExtJS (26)
- Linux (49)
- Windows (11)
- Web (8)
- Ubunt (9)
- Shell (21)
- MySQL (26)
- Redis (9)
- Git (6)
- Maven (29)
- Python (3)
- Nginx (10)
- Nodejs (7)
- Network (1)
- GO (2)
- Docker (36)
- MongoDB (5)
- Intellij idea (7)
- Ruby (3)
- Weblogic (3)
- CSS (15)
- VMware (3)
- Tomcat (6)
- Cache (2)
- PHP (8)
- Mac (7)
- jQuery (3)
- Spring (8)
- HTML5 (2)
- Kubernetes (8)
最新评论
-
masuweng:
Intellij idea 主题下载网址 -
mimicom:
还有一个情况, 也是连不上 2018-05-06T06:01: ...
docker-compose 部署shipyard -
lixuansong:
put()方法调用前必须先手动调用remove(),不然不会实 ...
JavaScript创建Map对象(转) -
jiao_zg22:
方便问下,去哪里下载包含Ext.ux.TabCloseMenu ...
Ext.ux.TabCloseMenu插件的使用(TabPanel右键关闭菜单) 示例 -
netwelfare:
对于基本类型的讲解,文章写的有点简单了,没有系统化,这篇文章介 ...
Java 基础类型范围
Listing all files from a directory with a giving suffix
最近办离职,需要列一下代码清单,网上找了段程序,保留一下。
import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class FilesReader { private static final String READ_PATH = "D:/WebRoot/market"; // private static final String SUFFIXAL_PATH = "java"; private static final String SUFFIXAL_PATH = "jsp"; // private static final String SUFFIXAL_PATH = "js"; /** * @param args */ public static void main(String[] args) { List arrayList = FilesReader.getListFiles(READ_PATH, SUFFIXAL_PATH, true); if (arrayList.isEmpty()) { System.out.println("没有符号要求的文件"); } else { String message = ""; message += "符号要求的文件数:" + arrayList.size() + "\r\n"; System.out.println(message); // String lastPath=""; for (Iterator i = arrayList.iterator(); i.hasNext();) { String temp = (String) i.next(); String path=temp.substring(0, temp.lastIndexOf("\\")); String name=temp.substring(temp.lastIndexOf("\\")+1,temp.length()); //System.out.println(temp); // if(!lastPath.equals(path)){ // lastPath=path; // System.out.println("\n"); // } System.out.println(name+"\t\t\t\t\t"+path); message += temp + "\r\n"; } // appendMethod("d:/ajax/menu.txt", message); } } public static List<String> fileList = new ArrayList<String>(); /** * * @param path * 文件路径 * @param suffix * 后缀名 * @param isdepth * 是否遍历子目录 * @return */ public static List getListFiles(String path, String suffix, boolean isdepth) { File file = new File(path); return FilesReader.listFile(file, suffix, isdepth); } public static List listFile(File f, String suffix, boolean isdepth) { // 是目录,同时需要遍历子目录 if (f.isDirectory() && isdepth == true) { File[] t = f.listFiles(); for (int i = 0; i < t.length; i++) { listFile(t[i], suffix, isdepth); } } else { String filePath = f.getAbsolutePath(); if (suffix != null) { int begIndex = filePath.lastIndexOf(".");// 最后一个.(即后缀名前面的.)的索引 String tempsuffix = ""; if (begIndex != -1)// 防止是文件但却没有后缀名结束的文件 { tempsuffix = filePath.substring(begIndex + 1, filePath .length()); } if (tempsuffix.equals(suffix)) { fileList.add(filePath); } } else { // 后缀名为null则为所有文件 fileList.add(filePath); } } return fileList; } /** * 方法追加文件:使用FilesReader * * @param fileName * @param content */ public static void appendMethod(String fileName, String content) { try { // 打开一个写文件器,构造函数中的第二个参数true表示以追加形式写文件 FileWriter writer = new FileWriter(fileName, true); writer.write(content + "\r\n"); writer.close(); } catch (IOException e) { e.printStackTrace(); } } }
发表评论
-
JSTL格式化时间戳
2017-08-02 16:06 1056JSTL格式化时间戳 参考:http://www.c ... -
小顶堆排序Java代码样例
2017-05-27 16:54 1135小顶堆排序Java代码样例 import java. ... -
jps(Java Virtual Machine Process Status Tool)
2017-03-12 14:31 721jps(Java Virtual Machine Proc ... -
Java 生成范围内的随机数
2017-03-02 17:32 871Java 生成范围内的随机数 public clas ... -
使用SetUniqueList构造不重复的ArrayList
2017-02-08 18:02 639使用SetUniqueList构造不重复的ArrayList ... -
Base64字符解码保存文件
2016-11-16 15:21 1028Base64字符解码保存文件 /** ... -
使用Java将PDF文件转成图片
2016-11-16 11:13 10804使用Java将PDF文件转成图片 import com. ... -
java 去掉html标签
2016-10-14 14:35 1128java 去掉html标签 参考: http:// ... -
JSTL el 根据动态key 获取map的value
2016-10-13 19:28 1283JSTL el 根据动态key 获取map的value ... -
Java List转成使用分隔符分隔的字符串
2016-08-25 10:48 1804Java List转成使用分隔符分隔的字符串 org ... -
Java 8 List转Map
2016-08-25 10:45 5415Java 8 List转Map 参考:http:// ... -
JRebel注册网址
2016-08-18 11:35 713JRebel注册网址 https: ... -
Java Calendar 获取本周的星期一
2016-06-18 02:25 5016Java Calendar 获取本周的星期一 // ... -
Failed to class-load type while reading annotation metadata. This is a non-fatal
2016-06-18 02:25 4804Failed to class-load type ... -
Java Calendar 获取上下午
2016-05-31 10:13 1292Java Calendar 获取上下午 Simple ... -
java.io.IOException: line too long
2016-01-12 10:13 2592java.io.IOException: line too ... -
java 编译、打包
2015-10-19 16:53 842java 编译、打包 linux 上编译java文 ... -
Java 读取UTF-8文件中文乱码
2015-10-14 16:10 3503Java 读取UTF-8文件中文乱码 InputS ... -
JSP中的两种包含页面的方法
2015-10-14 15:58 664JSP中的两种包含页面的方法 第一种:include ... -
给java代码加一行PACKAGE(在文件头添加一行)
2015-08-06 12:26 1497给java代码加一行PACKAGE(在文件头添加一行) ...
相关推荐
Listing the files inside a directory http://www.geekpedia.com/tutorial148_Listing-the-files-inside-a-directory.html
描述“Generate a files listing in html”进一步确认了这一点,它表明这个压缩包包含了一个可以将文件系统中的文件和目录转换为HTML格式的列表的软件。 在IT领域,这样的工具通常用于创建网站的索引页面,或者方便...
Simple Directory Listing可能已经考虑到了这一点,使用了媒体查询(Media Queries)和响应式布局,确保在手机、平板电脑和桌面设备上都能提供良好的用户体验。 八、性能优化 对于大量文件的目录,优化文件遍历的...
Listing all the machines alive on a network 243 Transferring files 247 Setting up an Ethernet and wireless LAN with script 250 Password-less auto-login with SSH 253 Running commands on remote host ...
cpio, lha and rar files with a single click. o All of the Midnight Commander operations work with the virtual file system, enabling you to do complex tasks. o Mouse support on the Linux console...
Working through the examples in this book, you will create 12 game prototypes in a variety of popular genres, from collection-based and shoot-em-up arcade games to side-scrolling platformers and ...
【项目资源】:包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。...【项目质量】:所有源码都经过严格测试,可以直接...
korweblog_directory_listing
多多返利系统后台无法打开,出现Directory Listing Denied This Virtual Directory does not allow contents to be listed. 解决办法文件!保证可用!
This method a new instance of a Listing object that contains only those advertisements whose name or description contains the string given by the parameter keyword. If the parameter keyword equals ...
Returning a range of characters from a string 59 Creating a string of repeated characters 60 Replacing ranges of characters contained within a string 60 Creating a reverse string 61 Converting a ...
【PHP Directory Listing 开源解决方案详解】 在Web开发中,服务器默认的目录列表通常只提供基本的文件和目录信息,对于用户来说,这种显示方式可能不够友好。PHP Directory Listing开源项目正是为了解决这一问题,...
标题中的"Code-Listing-8.1---Text-Files.zip_Programming with C"表明这是一个与C语言编程相关的代码示例集合,特别是涉及到文本文件处理的部分。在C编程中,处理文本文件是至关重要的,这通常包括读取、写入、追加...
You can copy the contents of the CD to your hard disk by running the setup program found in the CD's root directory, or you can retrieve the files directly from the CD's \Code directory. The \Code ...
And, from the very start, he decided that he would publish the code for anyone else to use and perhaps tinker with, but the author wrote it in such a way that also lets readers with limited knowledge...
- **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. - **...
Python核心编程第三版 各个章节的源代码 与内容 README "Core Python Programming", 2nd Edition...fully-recursive directory listing. The "all.zip" and "all.tgz" files represent snapshots of everything here.
-a 所有(all)。 -e 所有(every),比a更详细。 -f 取消保护。 -i 添加提示。 -p 强制执行。 -r 目录管理。 分屏显示的中途操作 空格<space> 继续打开下一屏; 回车<return> 继续打开下一行; b 另外开上...
On the downstream channel, all packets emanate from a single source, namely, the head end. Thus, there are no collisions in the downstream channel. In most American cities, the current ...