Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Recently created folder is not coming in file.listFiles() method()  RSS feed

 
Paddy Patil
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i have written 4 JUnit Test cases. 1st test calls our one main method of another class where the some file processing happens. in Success case all these files (10 files ) moves to Success dir (in JUnit test case 3rd, i am checking this ). If some of fiels fails in processing it moves to ERROR dir (in JUnit test case 2nd, i am checking this).

But problem is, In Success directory there could be previously processed files. so to find latest created folder in this Success folder i am ussing following code.

problem is i am not getting name of recently created folder in the list at line 1 , bcz of this my 3rd test is failing. Please advice me on it. old folder name is coming as value of lastMod varaible

Thanks in advanced
 
Greg Charles
Sheriff
Posts: 3014
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paddy, and welcome to Java Ranch!

The code in lines 3 - 15 you've posted looks all right, but I may be confused. You say it's failing at line 1, but that line wouldn't have any effect on the rest of the code. Also line 1 is call to a static method in DefaultBatcherServiceBean, so not only can we not tell why it's failing, we don't even know what it's supposed to do.

In other words, after line 15, lastModifedFolder should hold the subdirectory of archive_dir with the most recent modification date, but actualArcFiles will hold exactly what it did before you ran the line 3 - 15 code.
 
Paddy Patil
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Charles,

Thanks for your prompt response.

After lines 1 and line 7 , i have put two system.out, where i am printing length of arrays "actualArcFiles" and "files" . both these lines giving me 1 less than actually it should be (means. before executing my test case if there are 20 subdirectories in Success dir. it should show me lenthg of these arrays 21 but it shows me 20), bcz of this iam getting old subdirectory name. and my JUnit test case is failing.

I think above explanation gives you insight on my problem.

Regrads,
Pradip
 
Paddy Patil
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Friends,

Please help me out in this issue . i have mention the details beloww post.. Please have a look at it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!