/**
 * 
 */
package cn.strong.fastdfs.sink;

import java.io.File;
import java.io.IOException;
import java.nio.channels.FileChannel;

import cn.strong.fastdfs.utils.RxIOUtils;
import io.netty.buffer.ByteBuf;

/**
 * 将内容写入文件
 * 
 * @author liulongbiao
 *
 */
public class FileSink implements Sink {

	final File file;
	final FileChannel channel;

	public FileSink(File file) {
		this.file = file;
		this.channel = RxIOUtils.openFileChannel(file);
	}

	@Override
	public void close() throws IOException {
		RxIOUtils.closeQuietly(channel);
	}

	@Override
	public void write(ByteBuf buf) {
		try {
			buf.readBytes(channel, buf.readableBytes());
		} catch (IOException e) {
			throw new RuntimeException("write ByteBuf to file error", e);
		}
	}

}

@@ -778,11 +778,108 @@
 %0D%0A%09%7D%0D%0A%0D%0A
+%09/**%0D%0A%09 * %E8%8E%B7%E5%8F%96%E5%BA%95%E5%B1%82%E7%9A%84%E6%96%87%E4%BB%B6%0D%0A%09 * %0D%0A%09 * @return%0D%0A%09 */%0D%0A%09public File getFile() %7B%0D%0A%09%09return this.file;%0D%0A%09%7D%0D%0A%0D%0A
 %7D%0D%0A

add getFile