String txt = area.getText();
try{
  File file = new File("Infor.txt");
  BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
  out.write(txt);
  out.close;
}catch(Exception e){}

解决方案 »

  1.   

    对,就这样各你一个。拷贝文件的:
    ///////////////////////////文件拷贝/////////////////////////////////////////////
       //  参数:    from             源路径。
       //  参数:    to               目标路径。
       //  exception  IOException  Description of the Exception
    ///////////////////////////////////////////////////////////////////////////////
      public static void copy( String from, String to ) throws IOException {
        int BUFF_SIZE = 100000;
        byte[] buffer = new byte[ BUFF_SIZE ];
        InputStream in = null;
        OutputStream out = null;
        try{
          in = new FileInputStream( from );
          out = new FileOutputStream( to );      while ( true ){
            synchronized ( buffer ){
              int amountRead = in.read( buffer );
              if ( amountRead == -1 ){
                break;
              }
              out.write( buffer, 0, amountRead );
            }
          }
        }
        finally {
          if ( in != null ){
            in.close();
          }
          if ( out != null ){
            out.close();
          }
        }
      }
      

  2.   

    File file = new File("Infor.txt");中的Infor.txt是文件名吗?哪路径是什么呢?建立的文件在哪里呢?
      

  3.   

    Infor.txt在你运行文件的目录下。
      

  4.   

    体会一下我这种写法和上面的有什么不同:
    <%
    StringBuffer txtConcent = new StringBuffer() ;
    String sSrcName="c:\\test.txt";
    txtConcent.append("abc") ;try
    {
     java.io.PrintWriter pw = new java.io.PrintWriter(new java.io.FileWriter(sSrcName, true), true);//注意true的用法                           pw.println(txtConcent);
    pw.close();

    }  
    catch (Exception e)
    {

    }

    %>
      

  5.   

    File file = new File("Infor.txt");中的Infor.txt是文件名吗?哪路径是什么呢?建立的文件在哪里呢?
    在与你编译生成的CLASS文件的同一个目录里,要么你也可以单独指定这个文件的位置如
    File file = new File("c:\\Infor.txt");