标签:
//自定义文件过滤器
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"));
标签:
原文地址:http://www.cnblogs.com/ajmd/p/5484038.html