我有一个小程序,在按下提交按钮时会发生某些操作。 我在TextArea中打印了stackTrace。 我想将TextArea的内容写入文件。但文件中没有出现任何内容。 我哪里错了? 这是我的代码
public void actionPerformed(ActionEvent ae)
{
Firstname=t1.getText();
Lastname=t2.getText();
Birthdate=t3.getText();
if(r1.isSelected())
{Gender=r1.getText();
}
else
Gender=r2.getText();
State=t4.getText();
City=t5.getText();
Hobby=jl1.getSelectedItem();
Education=jl2.getSelectedItem();
Occupation=jl3.getSelectedItem();
HobbyS=Hobby.toString();
EducationS=Education.toString();
OccupationS=Occupation.toString();
JOptionPane.showMessageDialog( frame,"BEFORE FUNCTION CALL");
callFunction();
}
public void callFunction()
{
JOptionPane.showMessageDialog( frame,"IN FUNCTION");
String test;
String test1;
String test2;
JOptionPane.showMessageDialog( frame," CREATE OBJECT NOW");
EmbeddedNeo4j hello = new EmbeddedNeo4j();
JOptionPane.showMessageDialog( frame,"OBJECT CREATED");
test1=hello.verify(Firstname);
test2=hello.start() ; tExtra.setText(test2); String str= tExtra.getText(); try { FileWriter fr= new FileWriter("C:\\neo4j-community 1.9.6\\data\\graph.db\\connection\\st.txt"); BufferedWriter fileOut = new BufferedWriter(fr); fileOut.write(str); fileOut.close(); } catch (IOException ioe) { JOptionPane.showMessageDialog( frame,"NOT FOUND"); ioe.printStackTrace(); } test=hello.createDb(Firstname,Lastname,Gender,State,City,HobbyS,EducationS,OccupationS); JOptionPane.showMessageDialog( frame,test); }What am i doing wrong?