• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I/O K&B Question

 
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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() + " ");
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
You showed up just in time for the waffles! And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic