遍历所有对象

package pp;


import java.io.File;


import java.io.IOException;


public class file {
// f:/text/111.txt
// /aa.txt
// /aa/aaa.txt


public static void main (String[] args){
File file = new File("f:/text/aa");
file.mkdirs();

File file1 = new File("f:/text/111.txt");
File file2 = new File("f:/text/aa.txt");
File file3 = new File("f:/text/aa/aaa.txt");

try {
file1.createNewFile();
file2.createNewFile();
file3.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


System.out.println(file1.getPath()+"\n"+"\t"+file2.getName());
System.out.println("\t"+file3.toString().substring(file3.getParent().lastIndexOf("\\") , file3.toString().length()));
}
}

你可能感兴趣的:(遍历所有对象)