java 扫描指定目录,获取目录下所有文件

public  static  void  main( String[] args ){

    //读取目录
    String filePath = "C:\\Users\\meng\\Desktop\\dddd\\";
    String outFilePath = "C:\\Users\\meng\\Desktop\\cccc\\";
    File file=new File(filePath);
    File[] tempList = file.listFiles();
    System.out.println("该目录下对象个数:"+tempList.length);
    for (int i = 0; i < tempList.length; i++) {
        if (tempList[i].isFile()) {

            File tempFile = tempList[i];
            String fileName = tempFile.getName();
            int index = fileName.lastIndexOf('.');
            String ext = fileName.substring(index+1, fileName.length());
            String nameExceptExt = fileName.substring(0, index);
            dicom2Jpg( outFilePath, nameExceptExt, "jpg", tempFile  );
        }
    }
}

你可能感兴趣的:(javaWeb)