//自定义文件过滤器
import java.io.File; import javax.swing.filechooser.*; public class JavaChooser extends FileFilter{ @Override public String getDescription()
{
return ".java";
}
@Override
public boolean accept(File f) {
// TODO Auto-generated method stub
return f.isDirectory() || f.getName().endsWith(".java");
}
}
//设置文件名
String filename = selectedFile.getName();
int dot = filename.indexOf(".");
FileWriter fw = new FileWriter(new File(filename.substring(0,dot)+".txt"));