delele all files with an extension in java
<p>So I found some code earlier that looks like it would work but it doesn't call to delete the files just to list them. What do I need to add so that it deletes the files?</p>

<pre><code>import java.io.File;
import java.util.regex.Pattern;

public class cleardir {
    static String userprofile = System.getenv("USERPROFILE"); 

    private static void walkDir(final File dir, final Pattern pattern) {   
        final File[] files = dir.listFiles();   
        if (files != null) {     
            for (final File file : files) {       
                if (file.isDirectory()) {         
                    walkDir(file, pattern);       
                    } else if (pattern.matcher(file.getName()).matches()) { 
                        System.out.println("file to delete: " + file.getAbsolutePath());  
                        }     }   } }  
    public static void main(String[] args) {   
        walkDir(new File(userprofile+"/Downloads/Software_Tokens"), 
                Pattern.compile(".*\\.sdtid")); 
        } 
}
</code></pre>
