I know there's a method called renameTo() in File class. I tried using it. All the posts I found online suggested that all I need is a File object to the new file and call renameTo() method.
I tried all the possible combination and it didn't rename my file. I saw the all my file objects are given the right paths by printing out the file names. The only possible thing I can think of is the permission issues. So I even tried copying the files over to the Shared folder and still failed.
So, I ended up writing a method that copied over the content of the original file into the new file which has the new file name. After that, the old file gets deleted. And it worked and that was a prove that the permission wasn't the issue. I know it's a not-so-sophisticated approach. But it worked and I needed something that will work. Hopefully I will be able to use renameTo() without any problems one day.
No comments:
Post a Comment