public boolean exportToTxtFile() { Internal internal = BookUtil.get( this.mainFrame, SbConstants.BookKey.EXPORT_DIRECTORY, EnvUtil.getDefaultExportDir(this.mainFrame)); File file1 = new File(internal.getStringValue()); JFileChooser chooser = new JFileChooser(file1); chooser.setApproveButtonText(I18N.getMsg("msg.common.export")); chooser.setSelectedFile(new File(getFileName())); chooser.setFileFilter(new TextFileFilter()); int i = chooser.showOpenDialog(this.mainFrame); if (i == 1) { return false; } File outFile = chooser.getSelectedFile(); if (!outFile.getName().endsWith(".txt")) { outFile = new File(outFile.getPath() + ".txt"); } StringBuffer buffer = getContent(); try { try (BufferedWriter outStream = new BufferedWriter(new FileWriter(outFile))) { String str = buffer.toString(); outStream.write(HtmlUtil.htmlToText(str, true)); } } catch (IOException e) { return false; } JOptionPane.showMessageDialog( this.mainFrame, I18N.getMsg("msg.common.export.success") + "\n" + outFile.getAbsolutePath(), I18N.getMsg("msg.common.export"), 1); return true; }
@Override public void init() { try { Internal internal = BookUtil.get(mainFrame, BookKey.CHRONO_ZOOM, SbConstants.DEFAULT_CHRONO_ZOOM); setZoomedSize(internal.getIntegerValue()); } catch (Exception e) { setZoomedSize(SbConstants.DEFAULT_CHRONO_ZOOM); } }