你应该自己查资料作,遇到不明白的具体问题可以上来问问

解决方案 »

  1.   

    好的,我可以提供参考程序,明天给
      

  2.   

    import java.awt.*;
    import java.io.*;
    import java.awt.event.*;
    public class freeask 
    {
    public static void main(String []S)
    {
    new myframe();
    }
    }
    class myframe extends Frame implements ActionListener
    {
    TextArea t;
    Button bt;
    FileDialog f;
    myframe()
    {
    super("文本保存");
    this.setLayout(new FlowLayout());
    this.addWindowListener(new WindowAdapter(){
         public void windowClosing(WindowEvent e){
         dispose();
         System.exit(0);
         }
         });
    t=new TextArea(20,20);
    this.add(t);
    bt=new Button("保存文本");
    bt.addActionListener(this);
    this.add(bt);
    this.setSize(300,300);
    this.show();
    }
    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource()==bt)
    {
    f=new FileDialog(this,"选择保存的文件",FileDialog.SAVE);
    f.show();
    try
    {
    File myfile=new File(f.getDirectory(),f.getFile());
    RandomAccessFile r=new RandomAccessFile(myfile,"rw");
    String s=t.getText();
    r.writeChars(s);
    }catch(IOException ie){}

    }
    }
    }