Given the following code for monitoring a directory:
Path path = Paths.get(directoryPath);
WatchService watchService = FileSystems.getDefault().newWatchService(); path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_MODIFY,
StandardWatchEventKinds.ENTRY_DELETE);
while(true){
WatchKey key = watchService.take(); //waits until a key is available
System.out.println(key.isValid());
for (WatchEvent<?> watchEvent : key.pollEvents()) {
Kind<?> kind = watchEvent.kind();
System.out.println(kind); } }
A file is created and then deleted from the monitored directory.
How many events will be printed by the above code?
There are four option available.
A 1
B 2
C 3
D 4
Query - In questions above there is no system.out.println for printing events.
Answer is A - 1 event .
I would like to know , how 1 is came for said questions.
About Question enthuware.ocpjp.v8.2.1673 :
Moderators: Site Manager, fjwalraven
-
- Posts: 9
- Joined: Wed Nov 25, 2015 11:54 pm
- Contact:
-
- Site Admin
- Posts: 10402
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1673 :
You are right. It should be System.out.println(watchEvent); instead of System.out.println(kind); Fixed.
thank you for your feedback!
thank you for your feedback!
-
- Posts: 9
- Joined: Wed Nov 25, 2015 11:54 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1673 :
Thanks for fixed.
How i can get update in my system ?
What is the process to get updated questions and answer ?
How i can get update in my system ?
What is the process to get updated questions and answer ?
-
- Site Admin
- Posts: 10402
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.v8.2.1673 :
You may just download the question bank again from our website.
-Paul.
-Paul.
Who is online
Users browsing this forum: No registered users and 7 guests