Two Laptop Bag*
The moose likes Beginning Java and the fly likes I/O question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I/O question" Watch "I/O question" New topic
Author

I/O question

vibhas karn
Greenhorn

Joined: Aug 11, 2008
Posts: 26
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

Joined: Oct 13, 2005
Posts: 37890
    
  22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I/O question
 
Similar Threads
File Question
Having problem with question 12
Doubt in K&B concerning question 12
I/O K&B Question
Updated K&B 5 Errata - 4/16