• 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 question

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi friends its "Vibhas" this question is from Kaithy Seirra pg 504 question number 12 SCJP 1.5
import java.io.*;
public class Directories
{
static String[] dirs = {"dir1","dir2"};
public static void main(String[] args)
{
for(String d : dirs)
{


//insert code1 here
File file = new File(path,args[0]);

// insert code2 here
}
}
}

// I already had a directory dir1 and dir2 with files "file1.txt" and "file2.txt"
//respectively
// commandline java Directories file2.txt
// options:--
//a> String path = d; System.out.print(file.exists()+" ");
//b> String path = d; System.out.print(file.isFile()+" ");
//c> String path = File.separator + d;System.out.print(file.exists()+" ");
//d> String path = File.separator + d;System.out.print(file.isFile()+" ");
Can anybody 1st explain me the question what it is looking for then the answer with reasoning...
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by vibhas karn:
. . . Can anybody 1st explain me the question what it is looking for then the answer with reasoning...

First part, please. anybody. I don't have that book.

Second part: no chance. The idea of learning is for you to Do Your Own Homework; you will learn nothing at all if somebody else gives you the answer.
 
reply
    Bookmark Topic Watch Topic
  • New Topic