import java.io.File;
public class Test {
public static void main(String args[]) {
File file = new File("D:\\A\\B\\C");
file.mkdirs();
file = new File("D:\\A\\B\\D");
file.mkdir();
}
}
JAVA过滤文件
利用String的endWith来过滤文件
<pre name="code" class="java">public class FileFilter{
public static void main(String [] args){
String [] fileName = {"one.jpg","two.txt","three.doc","four.jpg","five.bat","six.bmp","seven.jpg"};
for(int i = 0; i < fileName.length; i++){
if(fileName[i].endsWith("jpg")){
System.out.print(fileName[i] + " ");
}
}
System.out.println();
}
}