aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes I/O K&B Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "I/O K&B Question" Watch "I/O K&B Question" New topic
Author

I/O K&B Question

Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
This is the self test question of K&B.

I did not under stand the question or the answer what it means.
Tried looking at the API but didn't help either.
Can some one please explalin what's going on?




And the invocation is
java Directores file2.txt

is issued from a directory that has two subdirectories "dir1" and "dir2" and that "dir1" has a file "file1.txt" and "dir2" has a file "file2.txt",
and the out put is :
false true

Which set of code fragments must be inserted?


1. String path=d;
System.out.println(file.exists() + " ");

2. String path=d;
System.out.println(file.isFile() + " ");

3. String path=File.separator + d;
System.out.println(file.exists() + " ");

4. String path=File.separator + d;
System.out.println(file.isFile() + " ");


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
sharad sinha
Greenhorn

Joined: Jul 13, 2008
Posts: 26

options 1 and 2 are correct. what is the problem?
You are already inside the directory from where the command is invoked.
In the first for loop file2.txt will not be found in dir1 and will be found in dir2.
In the second for loop file2.txt is not a file inside dir1 but is a file inside dir2.


Thanks, Sharad<br />SCJP 5 (July, 2008)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I/O K&B Question