H
harryos
hi
i want to use a function that takes a directory path name and prints
listing of files in it.The user may enter windows or unix style path
as input.
i tried this
public void directorylisting(String dirpath){
java.util.List imglist=new java.util.ArrayList();
final String ext=".jpg"
File pgmdir=new File(pgmdirname);
String[] children=pgmdir.list(new FilenameFilter(){
public boolean accept(File f,String name){
if(name.endsWith(ext))
return true;
else
return false;
}
});
System.out.println"children:"+children);
for (String i : children){
System.out.println(i);
}
}
this works if i enter directory name as
F:\\png\\galleryimages\\
or
F:/png/galleryimages/
but i want the windows user to enter only
F:\png\galleryimages\
Do i have to take the string and process it before calling the
function or is there any other way ?may be using FileSeparator or
something?can someone advise?
thanks
harry
i want to use a function that takes a directory path name and prints
listing of files in it.The user may enter windows or unix style path
as input.
i tried this
public void directorylisting(String dirpath){
java.util.List imglist=new java.util.ArrayList();
final String ext=".jpg"
File pgmdir=new File(pgmdirname);
String[] children=pgmdir.list(new FilenameFilter(){
public boolean accept(File f,String name){
if(name.endsWith(ext))
return true;
else
return false;
}
});
System.out.println"children:"+children);
for (String i : children){
System.out.println(i);
}
}
this works if i enter directory name as
F:\\png\\galleryimages\\
or
F:/png/galleryimages/
but i want the windows user to enter only
F:\png\galleryimages\
Do i have to take the string and process it before calling the
function or is there any other way ?may be using FileSeparator or
something?can someone advise?
thanks
harry