开发者

What should be the description for this method?

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 break statement will give a compilation error, I think. It should be a return.

  • It is bad style to name a field with a capital letter as the first character. If Dir and Map are field names, they should be dir and map respectively.

  • The statement Map = getMap(file); is going to repeatedly replace the Map field, and when you exit the loop, the field will refer to the object returned by the last getmap call. This is probably wrong.

  • Finally, change the file declaration as follows. (There is no need to create a new File object ... because getAbsoluteFile() reurns a File)

    File file = files[i].getAbsoluteFile();
    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜