你好我试图将文件保存在Jfilechooser指定的位置,现在的情况是用户点击保存文件是在项目方向上创建的,名称标题,但我需要的是给用户选项保存位置该文件并使用JFileChooser
选择他喜欢的名称if(buttonPressed.equals(save)){
File myFile = new File("title");
final JFileChooser fc = new JFileChooser();
int returnVal = fc.showSaveDialog(null);
fc.setSelectedFile(myFile);
if (returnVal == JFileChooser.APPROVE_OPTION) {
try (PrintWriter writer = new PrintWriter(myFile)) {
for (int i =0 ; i< cModel.getRowCount(); i++)
{
sData.add(cModel.getValueAt(i, 1).toString());
eData.add(cModel.getValueAt(i, 2).toString());
tData.add(cModel.getValueAt(i, 3).toString());
writer.println(i+1 + "\n");
writer.println(sData.get(i)+" --> " + eData.get(i));
writer.println(tData.get(i));
writer.println("\n");
}
}catch(FileNotFoundException ioEx){
}
}
}
答案 0 :(得分:0)
尝试
it('should throw an error.', function(done) {
myPromiseGenerator().then(function() {
done(new Error("should not succeed"));
}).catch(function(e) {
done();
})
}