這個小程式是要用來寫壓縮程式用的一小部份,但壓縮程式還有中文壓縮的問題還沒解決,所以先將這個可以再利用的部份整理出來
程式中因為希望得到的資訊能夠再利用,所以使用ArrayList將它輸出,如果資訊不需再利用則可以直接Print出來就行了。
原史碼:
public class Demo { public static void main(String[] args) { Demo demo = new Demo(); for(String tmp:demo.fileList("D:\\workspace\\XlsToCsv")){ System.out.println(tmp); } } private ArrayList fileList(String filePath){ ArrayList list= new ArrayList(); File file = new File(filePath); if(file.isDirectory()){ if(!filePath.matches(".*\\\\$")) filePath += "\\"; list.add(filePath); for(String fileName:file.list()){ list.addAll(this.fileList(filePath + fileName)); } return list; }else{ list.add(filePath.toString()); return list; } } }
輸出結果:
D:\workspace\XlsToCsv\ D:\workspace\XlsToCsv\.classpath D:\workspace\XlsToCsv\.project D:\workspace\XlsToCsv\.settings\ D:\workspace\XlsToCsv\.settings\org.eclipse.jdt.core.prefs D:\workspace\XlsToCsv\bin\ D:\workspace\XlsToCsv\bin\com\ D:\workspace\XlsToCsv\bin\com\ubot\ D:\workspace\XlsToCsv\bin\com\ubot\model\ D:\workspace\XlsToCsv\bin\com\ubot\model\ExcelUtil.class D:\workspace\XlsToCsv\bin\com\ubot\model\JavaMail.class D:\workspace\XlsToCsv\bin\com\ubot\model\ZipTools.class D:\workspace\XlsToCsv\bin\com\ubot\xlstocsv\ D:\workspace\XlsToCsv\bin\com\ubot\xlstocsv\XlsToCsv.class D:\workspace\XlsToCsv\CSV2015-02-11.ZIP D:\workspace\XlsToCsv\DB-Type.properties D:\workspace\XlsToCsv\Job-Type.properties D:\workspace\XlsToCsv\src\ D:\workspace\XlsToCsv\src\com\ D:\workspace\XlsToCsv\src\com\ubot\ D:\workspace\XlsToCsv\src\com\ubot\model\ D:\workspace\XlsToCsv\src\com\ubot\model\ExcelUtil.java D:\workspace\XlsToCsv\src\com\ubot\model\JavaMail.java D:\workspace\XlsToCsv\src\com\ubot\model\ZipTools.java D:\workspace\XlsToCsv\src\com\ubot\xlstocsv\ D:\workspace\XlsToCsv\src\com\ubot\xlstocsv\XlsToCsv.java D:\workspace\XlsToCsv\XLS-Formula.properties D:\workspace\XlsToCsv\XlsToCsv.properties
全站熱搜
留言列表