public static void deleteFile(File file)
    {
        if (file.isDirectory())
        {
        	File[] children = file.listFiles();
        	if (children != null)
        	{
        		for (File child : children)
        			deleteFile(child);
        	}
        	children = file.listFiles();
        	if (children == null || children.length == 0)
        	{
        		if (!file.delete())
        			System.out.println("Error: Could not delete folder: " + file.getPath());
        	}
        }
        else if (file.isFile())
        {
        	if (!file.delete())
        		System.out.println("Error: Could not delete file: " + file.getPath());
        }
    }