Java的目录文件读取: 程序代码为读取某个目录下的文件名: /**/ /* * ReadContent.java * * Created on 2006年12月10日, 下午2:40 * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package com.mrl;import java.io.* ;/** */ /** * * @author longronglin */ public class ReadContent... { /** *//** 正常文件目录 */ private static String FILE_DIR_NORMAL = "d:/testset"; /** *//** 非正常文件目录 */ private static String FILE_DIR_INNORMAL = ""; /** *//** Creates a new instance of ReadContent */ public ReadContent () ...{ } public static void main(String[] args) ...{ getFile(FILE_DIR_NORMAL); //getFile(FILE_DIR_INNORMAL); } public static void getFile(String dirPath) ...{ /** *//** 建立当前目录中文件的File对象 */ File filesDir = new File(dirPath); /** *//** 取得代表目录中所有文件的File对象数组 */ File list[] = filesDir.listFiles(); for(int i=0;i<list.length;i++) ...{ if(list[i].isFile()) ...{ System.out.println(list[i].getName()); } } }}