- File file = new File(“E:\黑马\java基础\已看\day19\video\File\19.14_File类(File类的概述和构造方法).avi”);
String parent = “E:\黑马\java基础\已看\day19\video”;
String child = “File\19.14_File类(File类的概述和构造方法).avi”;File file = new File( parent, child);
File file = new File(“zhouxiaowei.txt”);
System.out.println(file.createNewFile());
file.setReadable(false);
System.out.println(file.canRead());
file.setWritable(false);
System.out.println(file.canWrite());
System.out.println(file.isHidden());File dir = new File("airen"); dir.mkdir(); File dir2 = new File("aini\\xiaowei"); dir2.mkdirs(); File file1 = new File("guyulei.txt"); File file2 = new File("guyulei1109.txt"); file1.renameTo(file2); System.out.println(dir.isDirectory());
File file = new File(“guyulei1109.txt”);
System.out.println(file.getAbsolutePath());
System.out.println(file.getPath());
System.out.println(file.getName());
System.out.println(file.length());
System.out.println(file.lastModified());Date date = new Date(file.lastModified());
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy年MM 月dd日 HH:mm:ss”);
//System.out.println(data);
System.out.println(sdf.format(date));File dir = new File(“E:\黑马\java基础\已看\day19\video\File”);
String [] arr = dir.list();
for (String str : arr) {
System.out.println(str);
}File [] subFiles = dir.listFiles(); for (File f : subFiles) { System.out.println(f); }
- File file = new File(“E:\黑马\java基础\已看\day19\video\file”);
/*String arr[] = file.list();
for (String str : arr) {
if (str.endsWith(“.avi”)){
System.out.println(str);
}
}*/
File [] subFile = file.listFiles();
for (File f : subFile) {
if(f.isFile() && f.getName().endsWith(“.avi”)){
System.out.println(f);
}
} String arr[] = file.list(new FilenameFilter() {
@Override public boolean accept(File dir, String name) { File file = new File (dir,name); return file.isFile() && file.getName().endsWith(".avi"); } });