Iam working in a desktop application for windows version using java. In my application there is a requirement to search all .php
i use recursive methods;
and REGEX
my code :
import java.io.File;
public class Copier {
public static void find(String source,String rep)
{
File src=new File(rep);
if(src.exists() && src.isDirectory())
{
String[] tab=src.list();
for(String s:tab)
{
File srcc=new File(rep+""+s);
if(srcc.isFile())
{
if(srcc.getName().matches(".*"+source+"$"))
System.out.println(s);
}
else
find(source,srcc.getAbsolutePath());
}
}
}
public static void main(String[] args)
{
find(".php","C:");
}
}
But i have this exception :
Exception in thread "main" java.lang.NullPointerException
at Copier.find(Copier.java:11)
at Copier.find(Copier.java:21)
at Copier.main(Copier.java:28)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…