java.io.CharArrayWriter.write(char[] c, int off, int len) 方法寫入指定的字元的緩衝區到writer。
以下是 java.io.CharArrayWriter.write(char[] c, int off, int len) 方法的宣告:
public void write(char[] c, int off, int len)
c -- 字元緩衝區
off -- 從偏移量開始讀取字元
len -- 要寫入的字元數
該方法不返回任何值。
NA
下面顯示java.io.CharArrayWriter.write(char[] c, int off, int len)方法的例子。
package com.yiibai; import java.io.CharArrayWriter; public class CharArrayWriterDemo { public static void main(String[] args) { char[] ch = {'A','B','C','D','E'}; CharArrayWriter chw = null; try{ // create character array writer chw = new CharArrayWriter(); System.out.println("off = 3; len=2"); // write character buffer to the writer chw.write(ch, 3, 2); // get buffered content as string String str = chw.toString(); // print the string System.out.print(str); }catch(Exception e){ // for any error e.printStackTrace(); }finally{ // releases all system resources from writer if(chw!=null) chw.close(); } } }
讓我們來編譯和執行上面的程式,這將產生以下結果:
off = 3; len=2 DE