hadoop HDFS工具类---对hdfs的读、写
时间:2014-02-09 23:38:00
收藏:0
阅读:506
1、文件流写入hdfs
public static void putFileToHadoop(String hadoop_path, byte[] fileBytes) throws Exception {
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(hadoop_path), conf);
Path path = new Path(hadoop_path);
FSDataOutputStream out = fs.create(path);
// 控制复本数量-wt
fs.setReplication(path, (short) 1);
out.write(fileBytes);
out.close();
}如何获取文件流可以参考http://blog.csdn.net/smile0198/article/details/19015027
原文:http://blog.csdn.net/smile0198/article/details/19015405
评论(0)