看看这段能达到你的要求不
JFileChooser chooser = new JFileChooser();
        ExampleFileFilter filter = new ExampleFileFilter();
        filter.addExtension("xls");
        //filter.addExtension("gif");
        filter.setDescription("Excel文件");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showDialog(this, "确定");
        if (returnVal == JFileChooser.APPROVE_OPTION) {
          // create a new file
          String filepath=chooser.getSelectedFile().getPath();
          String filename=chooser.getSelectedFile().getName();
          int nindex=filename.indexOf(".xls");
          FileOutputStream fos;
          if(nindex<0){
            filename=filename+".xls";
            int nindex1=filepath.lastIndexOf("\\");
            String filepath1=filepath.substring(0,nindex1+1);
            //System.out.println(filepath1+filename);
            fos= new FileOutputStream(filepath1+filename);
          }
          else{
            fos= new FileOutputStream(chooser.getSelectedFile());
          }
}