最佳答案
Consider the code:
File file = new File("c:\\temp\\java\\testfile");
testfile is a file, and it may or may not exist.
I want to get the directory c:\\temp\\java\\ using the File object. How do I go about doing this?