ObjectOutputStream file=new ObjectOutputStream(new FileOutputStream("filename"));
file.writeObject(your string);

解决方案 »

  1.   

    刚才的是二进制的,或者这样也可以,
    try{
    FileOutputStream fs=new FileOutputStream("1.txt");
    String s="jkljlk";
    fs.write(s.getBytes());
    }catch(Exception e)
    {}
      

  2.   

       try{
         FileWriter fr = new FileWriter("g:\\data");
         BufferedWriter bw = new BufferedWriter(fr);
         String s = "asfssdgsg";     bw.write(s);
         bw.close();
         fr.close();   }
       catch(IOException e){}
      

  3.   

    String s1 = new String("asdf");
    try{
       PrintWriter pw = new PrintWriter(new FileOutputStream("c:\\e.exe"));
       pw.write(s1);
       pw.close();
    }catch(IOException io){}