byte[] b=strCount.getBytes();
tyr{
FileOutputStream outputfile =new FileOutputStream("albert.txt");
outputfile1.write(b);
}.......

解决方案 »

  1.   

    给个演示程序你吧:
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;public class Frame1
    {
      public static void main(String[] args)
      {
        JFrame frame = new SaveFrame();
        frame.show();
      }
    }
    class SaveFrame extends JFrame
    {
       private JTextField number;
       private JButton saveButton;
       private JButton readButton;
       private String fileName="count.txt";  public SaveFrame()
      {
        this.setTitle("operation on "+fileName);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        number = new JTextField("20",30);
        saveButton = new JButton("save");
        saveButton.addActionListener(new ActionListener()
        {
          public void actionPerformed(ActionEvent event)
          {
            if(number.getText().length()<=0) return;
            try
            {
              DataOutputStream dos=new DataOutputStream(
                  new FileOutputStream(new File(fileName)));
              dos.writeUTF(number.getText());
              dos.close();
            }
            catch(IOException e) {  e.printStackTrace();}
          }
         });
         readButton = new JButton("read from file");
         readButton.addActionListener(new ActionListener()
         {
           public void actionPerformed(ActionEvent event)
           {
             try
             {
               DataInputStream dis=new DataInputStream(
                  new FileInputStream(new File(fileName)));
               number.setText(dis.readUTF());
               dis.close();
             }
             catch(IOException e){  e.printStackTrace(); }
           }
         });
         this.getContentPane().setLayout(new FlowLayout());
         this.getContentPane().add(number);
         this.getContentPane().add(saveButton);
         this.getContentPane().add(readButton);
         this.pack();
        }
    }
      

  2.   

    有一个write()和一个flush()方法,你可以看一下帮助