开发者

Readings files from a directory

I need to read each file from a directory to parse them individualy when I give a direc开发者_如何学运维tory structure.

I check if it excists and if its valid .. etc and I can parse the file's individualy. But I have no idea how to do it :

I had a idea but it doesn't work :

String dir = userinput;
File directory = new File(dir);
File files[] = directory.listFiles();

for (File f : files){
    // parsing method    
}

I have a method that checks if it's a valid dir or file and I always get a return that the file isn't valid. If I read them individualy I have no problems


I don't know what the curly brackets before the for and after the close of the for loop are doing, but the logic seems sound enough. You might want to add some guards like isFile() isDirectory(), but I don't see why adding a parsing method in at the commented position would not work. What exactly is your problem?

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜