Page 1 of 1

About Question enthuware.ocpjp.v8.2.1401 :

Posted: Sun Nov 29, 2015 4:02 am
by lveto15
Presented code doesn't work exactly as explain in the question.

Code: Select all

File newfile = new File(oldfilename+".checked");
boolean b = oldFile.renameTo(newFile);
It renames file, but also moves it to the directory in which this code is executed.

Since subdirectories shouldn't be processed something like this can be done:

Code: Select all

String newName = args[0]+"/"+oldfilename;
File newfile = new File(newName+".checked");
boolean b = file.renameTo(newfile);

Re: About Question enthuware.ocpjp.v8.2.1401 :

Posted: Sun Nov 29, 2015 9:23 am
by admin
You are right. Fixed.
thank you for your feedback!