当前位置: 技术问答>java相关
15分买一判断呀!
来源: 互联网 发布时间:2015-02-05
本文导语: 我想判断他保存成功时:就弹出对话框,不成功也弹出对话框, 程序是对的,就是下面的弹出对话框是错的,请各位帮我改改!谢谢, void jButton1_actionPerformed(ActionEvent e) { ...
我想判断他保存成功时:就弹出对话框,不成功也弹出对话框,
程序是对的,就是下面的弹出对话框是错的,请各位帮我改改!谢谢,
void jButton1_actionPerformed(ActionEvent e) {
String currFileName = null;
// Handle the case where we don't have a file name yet.
if( currFileName == null ) {
Date iNow = new Date();
SimpleDateFormat iFormat = new SimpleDateFormat( "yyyy-MM-dd HH.mm.ss");
currFileName = iFormat.format( iNow );
}
try {
// Open a file of the current name.
File file = new File( currFileName +".txt" );
// file = file+".txt";
// Create an output writer that will write to that file.
// FileWriter handles international characters encoding conversions.
FileWriter out = new FileWriter( file );
String text = jTextArea1.getText();
out.write( text );
out.close();
// Display the name of the saved directory+file in the statusBar.
System.out.println( currFileName );
int iOK=oEreport.executeUpdate(out);
if(iOK==1){
JOptionPane.showMessageDialog(null, "保存成功!", "恭喜成功!",JOptionPane.INFORMATION_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null, "保存失败!", "错误失败!", JOptionPane.ERROR_MESSAGE);
}
}
catch (IOException el) {
el.printStackTrace();
}
}
程序是对的,就是下面的弹出对话框是错的,请各位帮我改改!谢谢,
void jButton1_actionPerformed(ActionEvent e) {
String currFileName = null;
// Handle the case where we don't have a file name yet.
if( currFileName == null ) {
Date iNow = new Date();
SimpleDateFormat iFormat = new SimpleDateFormat( "yyyy-MM-dd HH.mm.ss");
currFileName = iFormat.format( iNow );
}
try {
// Open a file of the current name.
File file = new File( currFileName +".txt" );
// file = file+".txt";
// Create an output writer that will write to that file.
// FileWriter handles international characters encoding conversions.
FileWriter out = new FileWriter( file );
String text = jTextArea1.getText();
out.write( text );
out.close();
// Display the name of the saved directory+file in the statusBar.
System.out.println( currFileName );
int iOK=oEreport.executeUpdate(out);
if(iOK==1){
JOptionPane.showMessageDialog(null, "保存成功!", "恭喜成功!",JOptionPane.INFORMATION_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null, "保存失败!", "错误失败!", JOptionPane.ERROR_MESSAGE);
}
}
catch (IOException el) {
el.printStackTrace();
}
}
|
gz
|
没什么不对吧
|
gz
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。