Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I/O question

 
vibhas karn
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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...
 
Campbell Ritchie
Sheriff
Pie
Posts: 49405
62
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic