I am experiencing wired behaviour using renameTo(). Can anyone lemme know wats the exact reason.
I have set of directories and file names in .properties file and i'm retriving those values and trying to move the file to temp directory
for ex:
app.properties file:
incoming=c:\\com\\incoming
dirctories=check1,check2
files=file1.txt,file2.txt
app.java :
forI(int i=0;i<arrDir.length;i++)
{
File f1 = new File(incoming+arrdirectories[i]+"
"+arrfiles[i]);
File f2 = new File(incoming+arrdirectories[i]+"\\"+"
temp"+arrfiles[i]);
f1.renameTo(f2);
}
If in case i provide
1 directory and 1 file, its moving the file
2 directory and 2 files, its moving only 2nd file.
3 directory and 3 files, its moving only 3rd file.
4 directory and 4 files, its moving only 4th file.
5 directory and 5 files, its moving all files.
6 directory and 6 files, its moving all files except last file.
NOTE: i'm not moving existing files. I have taken care of code part i.e. values from properties file are retrived properly.
-
Problem using renameTo method (1 messages)
- Posted by: Chetan Ramaiah
- Posted on: July 20 2008 02:51 EDT
Threaded Messages (1)
- More info by Martin Ivancic on July 21 2008 06:02 EDT
-
More info[ Go to top ]
- Posted by: Martin Ivancic
- Posted on: July 21 2008 06:02 EDT
- in response to Chetan Ramaiah
Hi Chetan Ramaiah, it seems to me that the problem occurs somewhere in the code that you didn't show. How do you fill variable arrdirectories and arrfiles? I know you said you properly retrieved those properties. But can you show us that part of code? What does arrDir variable in the for loop head stand for? Reagrds Martin.