有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java无法将JTextArea内容打印到文件中

我有一个小程序,在按下提交按钮时,某些操作会发生。 我在文本区打印了我的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?

共 (0) 个答案