실패 :저장 JTextPane가의 내용은 내가 코드의 덩어리 다음 한
private void saveAs()
{
CDocument currentDocument=this.panelMain().openedDocuments().get(this.panelMain().openedDocuments().size()-1);
StyledDocument contents=currentDocument.getStyledDocument();
DefaultEditorKit kit=new DefaultEditorKit();
JFileChooser chooserSaveAs=new JFileChooser();
chooserSaveAs.setDialogTitle("Save as ...");
if(chooserSaveAs.showSaveDialog(this)==JFileChooser.APPROVE_OPTION)
{
String strNewFilename=chooserSaveAs.getSelectedFile().getName();
BufferedOutputStream out;
try
{
out=new BufferedOutputStream(new FileOutputStream(strNewFilename));
kit.write(out,
contents,
contents.getStartPosition().getOffset(),
contents.getLength());
out.close();
}
catch(IOException | BadLocationException ex)
{
Logger.getLogger(CFrameMain.class.getName()).log(Level.SEVERE,
null,
ex);
}
}
}
가 실행되면,이 코드는 예외를 생성하지 않습니다,하지만 난 아무데도 디스크에 파일을 저장 찾을 수 없습니다 (내가 검색 한 총 사령관과 로컬 디스크를 통해). 생성 된 파일이없는 이유는 무엇입니까? 현재 Windows 7 Ultimate에서 작업 중이며 로그온 한 사용자의 데스크톱에 저장하려고했습니다 (가능한 액세스 위반 문제로 인해 ...)?
[SSCCE] (http://sscce.org/)에서 문제를 보여주는 글을 게시하십시오. – camickr
당신은 out.flush() 호출하려고 할 수 있습니다; 끝나기 전에? – StanislavL