JFileChooser chooser = new JFileChooser(); chooser.setFileFilter(new FileFilter(){ public boolean accept(File f){ //这里写上你想要得路径 if (f.getPath().toLowerCase().startsWith("d:\\excel")) return true; else return false; } /** * The description of this filter. For example: "JPG and GIF Images" * @see FileView#getName */ public String getDescription(){ return ""; } });
jiaminxy我不知道你为什么提Excel?
chooser.setFileFilter(new FileFilter(){
public boolean accept(File f){ //这里写上你想要得路径
if (f.getPath().toLowerCase().startsWith("d:\\excel"))
return true;
else
return false;
} /**
* The description of this filter. For example: "JPG and GIF Images"
* @see FileView#getName
*/
public String getDescription(){
return "";
}
});