• Post Reply Bookmark Topic Watch Topic
  • New Topic

renameTo()  RSS feed

 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
renameTo() API in file will be true if and only if the renaming is success. Else it will be false. So, When it fails, is there a way to check why it failed, say like some error codes as Permission denied, file not exists() sort of things. I have a application which does not renames the files if it is in the ROOT(/) direcotry. The platform ix UNIX.
 
Vijitha Kumara
Bartender
Posts: 4002
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check for the SecurityException thrown if the security manager exists and does not allow the write access.
 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SecurityException was not thrwon too. Please find below the code given,

 
Vijitha Kumara
Bartender
Posts: 4002
42
Chrome Fedora Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If file/dir does not exist why you continue the method? Then you will get false anyway if the file doesn't exists.
 
Vinney Shanmugam
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahhh! Thanks for pointing to it. But, I am worried when the file exists???
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The folder should exist, there just shouldn't be a file with the name in it. So change it like this:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!