A
alelvb
Hello,
I've written this toy-code to test the funcionality of the File class
and I've found a strange behaviour.
My code works only with the dot directory (the directory where the
Main.class is contained) and it doesn't with any other. What's the
problem?
here is the code
<cut here>
import java.io.*;
public class Main {
public static void main(String[] args){
File f = new File("."); // try to change the path
File[] file_array = null;
String[] content = null;
content = f.list();
file_array = new File[content.length];
boolean[] bool_array1 = new boolean[content.length];
boolean[] bool_array2 = new boolean[content.length];
for(int i=0; i<content.length; i++){
file_array = new File("." + "\\" + content);
bool_array1 = file_array.isDirectory();
bool_array2 = file_array.isFile();
System.out.println(content + "\tis a directory?: " +
bool_array1);
}
}
}
I've written this toy-code to test the funcionality of the File class
and I've found a strange behaviour.
My code works only with the dot directory (the directory where the
Main.class is contained) and it doesn't with any other. What's the
problem?
here is the code
<cut here>
import java.io.*;
public class Main {
public static void main(String[] args){
File f = new File("."); // try to change the path
File[] file_array = null;
String[] content = null;
content = f.list();
file_array = new File[content.length];
boolean[] bool_array1 = new boolean[content.length];
boolean[] bool_array2 = new boolean[content.length];
for(int i=0; i<content.length; i++){
file_array = new File("." + "\\" + content);
bool_array1 = file_array.isDirectory();
bool_array2 = file_array.isFile();
System.out.println(content + "\tis a directory?: " +
bool_array1);
}
}
}