Option 3: "You can create files in any directory using File class's API."
You can create files in any directory if you have rights for that, isn't it?
About Question enthuware.ocpjp.v7.2.1402 :
Moderator: admin
-
- Posts: 35
- Joined: Mon Jul 28, 2014 2:05 am
- Contact:
-
- Site Admin
- Posts: 10066
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1402 :
Yes, you will need to assume that such things are in order. Otherwise, there are a lot of dependencies and a question will not be able to list all. For example, if there is free disk space, and if the disk is writable, and if the directory doesn't contain a file by the same name already.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 35
- Joined: Mon Jul 28, 2014 2:05 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1402 :
I see, thx, Paul
-
- Posts: 19
- Joined: Wed May 25, 2016 4:33 am
- Contact:
Re: About Question enthuware.ocpjp.v7.2.1402 :
Hello,
option #4:
//assume that test.txt exists, and hmm.txt does not:
File f = new File("test.txt");
Files.move(f.toPath(),new File("hmm.txt").toPath());
System.out.printf("%s - %b", f, Files.exists(Paths.get("hmm.txt")));
--> test.txt - true
In any case, if one would argue that i should restrict my argument only to java.io.File, even then you can use renameTo(), whilst it won't change the original file object (ref var will point to a new file object and the other one will be garbage collected i assume), it will still change the underlying path!
Option #4 does not say anything that we can't change the File object instances, it only talks about changing the underlying, whether that underlying is represented by an instance of Path, File or whatever shouldn't matter.
Cheers,
Dieter
option #4:
//assume that test.txt exists, and hmm.txt does not:
File f = new File("test.txt");
Files.move(f.toPath(),new File("hmm.txt").toPath());
System.out.printf("%s - %b", f, Files.exists(Paths.get("hmm.txt")));
--> test.txt - true
In any case, if one would argue that i should restrict my argument only to java.io.File, even then you can use renameTo(), whilst it won't change the original file object (ref var will point to a new file object and the other one will be garbage collected i assume), it will still change the underlying path!
Option #4 does not say anything that we can't change the File object instances, it only talks about changing the underlying, whether that underlying is represented by an instance of Path, File or whatever shouldn't matter.
Cheers,
Dieter
Who is online
Users browsing this forum: No registered users and 213 guests