public static void main(String[] args) throws IOException
{
File dir = new File("f:\\abc");
copyPic(dir);
}
public static void copyPic(File dir) throws IOException
{
File[] files = dir.listFiles();
if (files!=null){
for(File f : files)
{
if(f.isDirectory())
copyPic(f);
else
if(f.getName().endsWith(".jpg"))
{
BufferedInputStream fi = new BufferedInputStream(new FileInputStream(f.getAbsolutePath()));
BufferedOutputStream fo = new BufferedOutputStream(new FileOutputStream(f.getName()));
int by = 0;
while((by=fi.read())!=-1)
fo.write(by);