New to Java
Hi,
everyone. I am new to Java and I have a big assignment due by next week. I have found one method of filtering file names. When I tried compiling the code, I got error message.
the code is:
--
from: http://home.cogeco.ca/~ve3ll/jatutor8.htm
public class OnlyExt implements FileNameFilter
{
String ext;
public OnlyExt(String ext)
{ this.ext = "." + ext; }
public boolean accept(File dir, String name)
{ return name.endsWith(ext); }
}
class DirListOnly
{
public static void main(String args[])
{
String dirname="./website";
File f1 = new File(dirname);
FileNameFilter only = new OnlyExt("xml");
String s[] = f1.list(only);
for (int i=0; i<s.length; i++)
{ System.out.println(s); }
}
}
--
The error message is:
C:\OnlyExt.java:3: cannot resolve symbol
symbol : class FileNameFilter
location: class OnlyExt
public class OnlyExt implements FileNameFilter
^
C:\OnlyExt.java:17: cannot resolve symbol
symbol : class FileNameFilter
location: class DirListOnly
FileNameFilter only = new OnlyExt("xml");
^
2 errors
Tool completed with exit code 1
If anybody can help me what I am doing wrong?
I changed the file name to be filtered from html --> xml. that's the only change i made.
thanks a lot

