// NewCompressWriter wrap the io.Writer
184171
func NewCompressWriter(w io.Writer) *compressWriter {
	p := &compressWriter{writer: w}
	p.data = make([]byte, BlockMaxSize, BlockMaxSize)

	zlen := lz4.CompressBound(BlockMaxSize) + HeaderSize
	p.zdata = make([]byte, zlen, zlen)
	return p
}
310386
func NewWriter(prefix string, flags int, handler events.Handler) *Writer {
	return &Writer{
		handler: handler,
		prefix:  prefix,
		flags:   flags,
	}
}
978005
func NewEncoder(w io.Writer) *Encoder {
	if w, ok := w.(FlushWriter); ok {
		return &Encoder{w}
	}

	return &Encoder{noopFlusher{w}}
}
645379
func NewWriter(f db.File, o *db.Options) *Writer {
	w := &Writer{
		closer:               f,
		blockRestartInterval: o.GetBlockRestartInterval(),
		blockSize:            o.GetBlockSize(),
		cmp:                  o.GetComparer(),
		compression:          o.GetCompression(),
		filter: filterWriter{
			policy: o.GetFilterPolicy(),
		},
		prevKey:  make([]byte, 0, 256),
		restarts: make([]uint32, 0, 256),
	}
	if f == nil {
		w.err = errors.New("leveldb/table: nil file")
		return w
	}
	// If f does not have a Flush method, do our own buffering.
	type flusher interface {
		Flush() error
	}
	if _, ok := f.(flusher); ok {
		w.writer = f
	} else {
		w.bufWriter = bufio.NewWriter(f)
		w.writer = w.bufWriter
	}
	return w
}
1210013
func (gz *Gz) Compress(in io.Reader, out io.Writer) error {
	w, err := gzip.NewWriterLevel(out, gz.CompressionLevel)
	if err != nil {
		return err
	}
	defer w.Close()
	_, err = io.Copy(w, in)
	return err
}
39705
func NewWriter(addr string) (*Writer, error) {
	var err error
	w := new(Writer)
	w.CompressionLevel = flate.BestSpeed

	if w.conn, err = net.Dial("udp", addr); err != nil {
		return nil, err
	}
	if w.hostname, err = os.Hostname(); err != nil {
		return nil, err
	}

	w.Facility = path.Base(os.Args[0])

	return w, nil
}
1362609
func NewWriter(dest io.Writer, state ws.State, op ws.OpCode) *Writer {
	return NewWriterBufferSize(dest, state, op, 0)
}
874297
func NewChunkedWriter(wr io.Writer, chunk int) io.Writer {
	return &chunkedWriter{wr, chunk}
}
933195
func NewWriter(w io.Writer, h *sam.Header, wc int) (*Writer, error) {
	return NewWriterLevel(w, h, gzip.DefaultCompression, wc)
}
789351
func (s *File) NewWriter(id string) (io.WriteCloser, error) {
	const mod = os.O_WRONLY | os.O_CREATE | os.O_TRUNC
	name := s.Prefixed.Name(id)

	if filepath.Dir(name) == "." {
		return os.OpenFile(s.join(name), mod, 0600)
	} else if !s.AllowSub {
		return nil, errors.New("sub directories not allowed")
	}
	if err := os.MkdirAll(s.join(filepath.Dir(name)), 0700); err != nil {
		return nil, err
	}
	return os.OpenFile(s.join(name), mod, 0600)
}
224467
func CompressStream(dest io.WriteCloser, compression Compression) (io.WriteCloser, error) {
	p := pools.BufioWriter32KPool
	buf := p.Get(dest)
	switch compression {
	case Uncompressed:
		writeBufWrapper := p.NewWriteCloserWrapper(buf, buf)
		return writeBufWrapper, nil
	case Gzip:
		gzWriter := gzip.NewWriter(dest)
		writeBufWrapper := p.NewWriteCloserWrapper(buf, gzWriter)
		return writeBufWrapper, nil
	case Bzip2, Xz:
		// archive/bzip2 does not support writing, and there is no xz support at all
		// However, this is not a problem as docker only currently generates gzipped tars
		return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension())
	default:
		return nil, fmt.Errorf("Unsupported compression format %s", (&compression).Extension())
	}
}
1204249
func NewBatchedFileWriter(file *os.File, compressOnClose bool, logger logrus.FieldLogger) BatchedFileWriter {
	return BatchedFileWriter{
		file,
		compressOnClose,
		nil,
		logger,
	}
}
1280235
func NewWriter(w io.Writer, bo binary.ByteOrder) Writer {
	return &writer{
		w:  w,
		bo: bo,
	}
}
570567
func NewWriterLoader(source io.Writer) (JSONLoader, io.Writer) {
	buf := &bytes.Buffer{}
	return &jsonIOLoader{buf: buf}, io.MultiWriter(source, buf)
}
1218481
func NewWriteCloser(w io.Writer, c io.Closer) io.WriteCloser {
	return &writeCloser{Writer: w, closer: c}
}
667445
func NewWriter(w io.Writer) *Writer {
	return &Writer{
		w:   w,
		ctx: context.Background(),
	}
}
1273420
func NewWriter(w io.Writer) (io.Writer, error) {
	tr, err := toCp949()
	if err != nil {
		return nil, err
	}

	return &cp949Writer{w: w, tr: tr}, nil
}