mayrontc 23 de abr. de 2009
Obrigado pela dica mais naum funcionou e ainda deu este erro.
h - ghjava . io . IOException : Stream closed
at java . io . BufferedWriter . ensureOpen ( Unknown Source )
at java . io . BufferedWriter . flushBuffer ( Unknown Source )
at java . io . BufferedWriter . flush ( Unknown Source )
at br . facet . si . paradigmas . telas . CadastroNome . gravarEmArquivoTXT ( CadastroNome . java : 177 )
at br . facet . si . paradigmas . telas . CadastroNome . access $ 0 ( CadastroNome . java : 165 )
at br . facet . si . paradigmas . telas . CadastroNome $ 2. actionPerformed ( CadastroNome . java : 140 )
at javax . swing . AbstractButton . fireActionPerformed ( Unknown Source )
at javax . swing . AbstractButton $ Handler . actionPerformed ( Unknown Source )
at javax . swing . DefaultButtonModel . fireActionPerformed ( Unknown Source )
at javax . swing . DefaultButtonModel . setPressed ( Unknown Source )
at javax . swing . plaf . basic . BasicButtonListener . mouseReleased ( Unknown Source )
at java . awt . Component . processMouseEvent ( Unknown Source )
at javax . swing . JComponent . processMouseEvent ( Unknown Source )
at java . awt . Component . processEvent ( Unknown Source )
at java . awt . Container . processEvent ( Unknown Source )
at java . awt . Component . dispatchEventImpl ( Unknown Source )
at java . awt . Container . dispatchEventImpl ( Unknown Source )
at java . awt . Component . dispatchEvent ( Unknown Source )
at java . awt . LightweightDispatcher . retargetMouseEvent ( Unknown Source )
at java . awt . LightweightDispatcher . processMouseEvent ( Unknown Source )
at java . awt . LightweightDispatcher . dispatchEvent ( Unknown Source )
at java . awt . Container . dispatchEventImpl ( Unknown Source )
at java . awt . Window . dispatchEventImpl ( Unknown Source )
at java . awt . Component . dispatchEvent ( Unknown Source )
at java . awt . EventQueue . dispatchEvent ( Unknown Source )
at java . awt . EventDispatchThread . pumpOneEventForFilters ( Unknown Source )
at java . awt . EventDispatchThread . pumpEventsForFilter ( Unknown Source )
at java . awt . EventDispatchThread . pumpEventsForHierarchy ( Unknown Source )
at java . awt . EventDispatchThread . pumpEvents ( Unknown Source )
at java . awt . EventDispatchThread . pumpEvents ( Unknown Source )
at java . awt . EventDispatchThread . run ( Unknown Source )
mayrontc 23 de abr. de 2009
Pedrosa 23 de abr. de 2009
Tente algo assim:
private void geraArquivo ( String conteudo ) {
try {
FileWriter writer = new FileWriter ( new File ( "C:/pnp.txt" ));
PrintWriter saida = new PrintWriter ( writer );
saida . print ( conteudo );
saida . close ();
writer . close ();
System . out . println ( "Arquivo criado com sucesso!" );
} catch ( Exception e ) {
e . printStackTrace ();
}
}
marciorja 23 de abr. de 2009
O flush deve ser realizado logo antes de fechar o arquivo.
O codigo deve ser:
e não
mayrontc 23 de abr. de 2009
brigadão ajudou muito, valeu!!