您的位置:首页 > 移动开发

HDFS文件追加append

2013-11-21 23:35 429 查看
HDFS文件追加hdfs中文件可以追加写,步骤如下:1、配置集群(hdfs-site.xml),必须配置才可以 <property>
<name>dfs.support.append</name>
<value>true</value>
</property>
2、API实现

String hdfs_path= "hdfs://ip:xx/file/fileuploadFileName";//文件路径
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(hdfs_path), conf);
InputStream in = new BufferedInputStream(new FileInputStream(file));//要追加的文件流,file为文件
OutputStream out = fs.append(new Path(hdfs_path));
IOUtils.copyBytes(in, out, 4096, true);


本文出自 “carrie倩” 博客,转载请与作者联系!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: