文件?
 什么文件
你先要写个Frame
 在把TextArea 加进去

解决方案 »

  1.   

    import java.io.*;
    import java.awt.*;public class Save
    {
      public static void main(String[] args)
       throws IOException
      {
        TextArea ta=new TextArea("this is \n a text");
        FileOutputStream f =new FileOutputStream("test.txt");
        f.write(ta.getText().getBytes());
      }
    }
      

  2.   

    不行
    TextArea中的数据还是没读出来
    出错了
    cannot resolve symbol
    symbol  : method write (java.lang.String)
    location: class java.io.File
    outputFile.write(output.getText());
              ^
      

  3.   

    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;public class Test extends Frame{
    private TextArea t = new TextArea();

    public Test(){
    Button b = new Button("Save");

    add("Center",t);
    add("South",b);

    pack();

    b.addActionListener(new ActionListener(){
    public void actionPerformed(ActionEvent ae){
    try{
    FileOutputStream fos =new FileOutputStream("test.txt");
    fos.write(t.getText().getBytes());
    }catch(IOException ie){
    ie.printStackTrace();
    }
    }
    });

    addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent we){
    System.exit(0);
    }
    });

    }

    public static void main(String args[]){
    new Test().show();
    }
    }如果t.getText()没有得到值  就先t.selectAll()然后在t.getText()
      

  4.   

    还是不行啊
    void cannot be dereferenced
    out.write(output.selectAll().getText().getBytes());
                              ^
      

  5.   

    我想问一下,你是想写到随机生成的txt文件中吗?
      

  6.   

    其实这个问题很简单,没有什么技术难度,你只需要看看书就明白了。只是注意,如果你输入的时中文,那么你还需要砖码!不然你在你的txt文件中看到的会是乱码。