0
CAN ANYBODY SOLVE THIS? Why error?
import java.io.File; import java.util.Date; public class Program { public static void main(String[] a[]) { File file = new File("/home/students") ; String[] filelist = file.list(); for(String name: fileList){ System.out.println(name); } } }
7 ответов
+ 1
It shows cannot find symbol
0
replace main(string[] arg[]) by main(string[] arg)
file.list() throw SecurityExeption, you have too surround your code with a try/catch block
What is your error?
0
Have you try What I suggested ☝️
public static void main(String[] a)
0
Mustakim Rahman
Check spelling of 'fileList' and 'filelist'
Also there should be:
main(String[] a)
You will get nullpointer exception
0
list() can return null if the path in File() does not exist
import java.io.File;
import java.util.Date;
public class Program {
public static void main(String[] a) {
File file = new File("/home/students") ;
String[] fileList = file.list();
System.out.println( fileList); //
if (fileList != null) {
for( String name: fileList){
System.out.println(name);
}
}
}
}
0
Take care about path of your file relatively to project folder.
0
I need help with the passport vehicle