https://www.dropbox.com/s/twtl38huxeeetsx/ProgettoApachePoi.rar
in this link there is my project, i create a java text editor for open docx documents. the text editor should do the basics functions of a text editor, as copy, paste , select all, delete, exit, new, open , save and save as. i tested the code and i have a problem only with the function "save", because the program don't do anything, but " save as" it run correctly. could someone help me to solve the problem. the part of the code that is about "save" is this:
private void SaveActionPerformed(java.awt.event.ActionEvent evt) {
if("".equals(CurrentFileDirectory)){
JFileChooser sdChooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter("Text file", "txt");
sdChooser.setFileFilter(filter);
int returnval = sdChooser.showOpenDialog(null);
try{
if(returnval == JFileChooser.APPROVE_OPTION){
File directory = sdChooser.getCurrentDirectory();
String path = directory.getAbsolutePath();
String fileName = sdChooser.getSelectedFile().getName();
if(fileName.contains(".docx")){
}else{
fileName = fileName + ".docx";
}
jTextArea.exportDocument(new FileOutputStream(new File(fileName)));
//BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(path + "\\" + fileName)));
//bw.write(jTextArea.getText());
//bw.close();}
}
}catch(IOException e){
JOptionPane.showMessageDialog(null, "ERROR!");
}
}
}