javascript
Brief description  about Online courses   join in Online courses
View n n n 's Profile

Input./output-reading directory

Hi,
I have a directory under the name 'Nitoo' containing another 2 directory Nitoo1 and Nitoo2 with 2 files name1 and name2. the path is as follows:C:\java project module\Nitoo,C:\java project module\Nitoo\Nitoo1,etc..

my program is as follows:

import java.io.File;

class ListOfDirectories{
public static void main(String args[]){
String directname = "/Nitoo";
File file1 = new File(directname);
if(file1.isDirectory()){

System.out.println("Directory of" directname);
String size[] = file1.list();
for(int i=0; i<size.length;i ){
File file2 = new File(directname "/" size[i]);
if(file2.isDirectory()){
System.out.println(size[i] "is a directory");
} else{
System.out.println(size[i] "is a file");
}
}
} else {
System.out.println(directname " is not a directory");
}
}


The program is compiling, but on executing instead of displaying the hierarchy, it is saying "/Nitoo is not a directory",please can you see my mistake??

Thank you,
Nitoo.
Asked by n n n | May 22, 2012 |  Reply now
Replies (0)