write(byte[] b, int off, int len) 
          Writes len bytes from the specified byte array starting at offset off to this file output stream.

解决方案 »

  1.   

    写字符串直接套PrintWriter,套Writer的子类都可以...
      

  2.   

    public void write(byte[] b,
                      int off,
                      int len)
               throws IOExceptionParameters:
    b - the data.
    off - the start offset in the data.
    len - the number of bytes to write.
      

  3.   

    public static void writeFile(String str, String filename) throws Exception 
       {
          // Open a writer to the file, then write the string.
          BufferedWriter bwriter;//writer to the file
          String fullfilepath;//path for the output file
          try 
          {
             bwriter = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename)));
             bwriter.write(str);
             bwriter.flush();
             bwriter.close();
          }//try
          catch(Exception e) 
          {
             throw e;
          }//catch
      

  4.   

    偏移位字节开始与b[10]的话偏移3就从b[3]开始
    共写出多少长度Parameters:
    b - the data.
    off - the start offset in the data.
    len - the number of bytes to write.
      

  5.   

    String 类型的一个变量怎么放进文件里呢?
      

  6.   

    <%
    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);
    pw.println(txtConcent.toString());
    }  
    catch (Exception e)
    {

    }

    %>