This content has been marked as final. Show 2 replies
darky wrote:In your class:
so...i have a folder in which i have 35 000 txt files..
i have to create a class which goes through that folder and gets me the files one by one...and the class' method must return me a txt file...and each time i call it from another method...it has to get me another file...hoe do i do that?
i found something in java.io.file but i think it uses constructor...and i kind of new in java so i don't really understand that..
cand you hepl me please...
i have to return a distinct txt file from that folder every time that method is called..
- read all files from that directory using File's listFiles() method.
- put all the files you're intersted in on a java.util.Stack
- each time a file is requested, pop it from the stack
And please don't ask for "sample codes", I don't have any. Try it yourself first, and when you get stuck, ask a specific question about YOUR code here on the forum.
Is it likely that any files will be added or removed from the directory whilst you are processing?