Skip to content

Commit

Permalink
Create Writer_Flush.md
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-wang committed Mar 12, 2013
1 parent 6d8b7ac commit 694e38d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bufio/Writer_Flush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## func (b *Writer) Flush() error

返回值

- 错误

功能说明

- Flush把已经写入缓冲区的数据写入底层的io.Writer

代码示例

package main

import (
"bufio"
"bytes"
"fmt"
)

func main() {
wb := bytes.NewBuffer(nil)
w := bufio.NewWriter(wb)
w.Write([]byte("123456"))
fmt.Printf("%d:%s\n", len(wb.Bytes()), string(wb.Bytes()))
w.Flush()
fmt.Printf("%d:%s\n", len(wb.Bytes()), string(wb.Bytes()))
}

代码输出

0:
6:123456

0 comments on commit 694e38d

Please sign in to comment.