# what does 'File path = new File(".");' mean?java
project root pathide
# how to see a directory listing?
spa
list(): return String[] code
list(FilenameFilter)orm
class DirFilter implements FilenameFilter { private Pattern pattern; public DirFilter(String regex) { pattern = Pattern.compile(regex); } /** my only reason for existence * callback * strategy design pattern * */ @Override public boolean accept(File dir, String name) { return pattern.matcher(name).matches(); } }
# rename fileget
File old = new File(args[1]), rname = new File(args[2]); old.renameTo(rname);
# file attributesit
f.getPath(); f.getAbsolutePath() f.canRead() f.canWrite() f.getName() f.getParent() f.length() f.lastModified() f.isFile() f.isDirectory()