About Question com.enthuware.ets.scjp.v6.2.135 :
Moderator: admin
About Question com.enthuware.ets.scjp.v6.2.135 :
Answer "You can create files in any directory using File class's API." is misleading because on any platform there are places that are system protected or there are other permissions that will not allow to create new file/directory (in example: home directory of another user).
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.135 :
What you say is true but the API itself poses no restrictions. For example, you can't create a file if the disk is full either but that is not what the statement implies.
HTH,
Paul.
HTH,
Paul.
If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Thu Jul 03, 2014 5:11 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.135 :
Option
This code changes the file that the File object represents:
Note, that "the file" term is used, not "the path to file".
should be matched.Once created there is no way to change the file or directory that the File object represents.
This code changes the file that the File object represents:
Code: Select all
File file1 = new File("file1.txt");
File file2 = new File("file2.txt");
File tempFile = new File("temp_file.txt");
file1.renameTo(tempFile);
file2.renameTo(file1);
file1.delete();
-
- Posts: 15
- Joined: Sun Aug 06, 2017 2:37 am
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.135 :
Please explain why option 4 is correct?
explanation given -Instances of the File class are immutable; that is, once created, the abstract pathname represented by a File object will never change
explanation given -Instances of the File class are immutable; that is, once created, the abstract pathname represented by a File object will never change
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.135 :
Because as the explanation says, you can't change the File object after creation. There are no setter methods or public fields in this class. You have to create a new File object if you want to represent a different file.
If you like our products and services, please help us by posting your review here.
-
- Posts: 10
- Joined: Fri Nov 18, 2016 5:48 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.135 :
why this is not consider as transverse ?
java.io.File a = new File("/");
Arrays.stream(a.list()).limit(10).forEach(System.out::println);
java.io.File a = new File("/");
Arrays.stream(a.list()).limit(10).forEach(System.out::println);
-
- Site Admin
- Posts: 10065
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.135 :
You are right. This question is not good. It is too vague and should be removed.
thank you your feedback!
thank you your feedback!
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: Bing [Bot] and 118 guests