I don't know Java but you should inspect these lines:
String p="fold";
File dir=new File(p);
File[] files=dir.listFiles();
for(File f : files)
if(f.isFile())
According to your comment, the execption is thrown in the last line: ryy.main(tryy.java:15)
The passed path "fold" looks suspect and I assume that
dir
will not be initialised to an existing directory. Then your
files
variable will be
NULL
:
public File[] listFiles()
Returns an array of abstract pathnames denoting the files in the directory denoted by this abstract pathname.
If this abstract pathname does not denote a directory, then this method returns null.
In the following
for
loop
f
will become
NULL
too and the next command
f.isFile()
(in line 15) will throw the exception.