OK this method reads a dirctor, verify the file paths are ok and then pass each file to a method and updates a Map object. But how 开发者_StackOverflowcan i explain this for java doc. I want to create a java doc and how should i explain this method for the documentation purpose. Please tell me, if you can help me with this example, i can work for my whole project. thank you:
private void chckDir() {
File[] files = Dir.listFiles();
if (files == null) {
System.out.println("Error");
break;
}
for (int i = 0; i < files.length; i++) {
File file = new File(files[i].getAbsoluteFile().toString());
Map = getMap(file);
}
}
Your method doesn't do what you said In your first sentence (doesn't verify file paths, and throws the result of getMap() away), but there's nothing wrong with putting that kind of sentence im the Javadoc.
There are some issues with your code:
The
breakstatement will give a compilation error, I think. It should be areturn.It is bad style to name a field with a capital letter as the first character. If
DirandMapare field names, they should bedirandmaprespectively.The statement
Map = getMap(file);is going to repeatedly replace theMapfield, and when you exit the loop, the field will refer to the object returned by the lastgetmapcall. This is probably wrong.Finally, change the
filedeclaration as follows. (There is no need to create a new File object ... becausegetAbsoluteFile()reurns aFile)File file = files[i].getAbsoluteFile();
加载中,请稍侯......
精彩评论