使用IO流操作hdfs
前期准备
- 安装hdfs集群
- 在需要调试的机器上配置hadoop环境变量
- 准备一个用来测试
test.txt
文件
准备FileSystem连接
public class HdfsClient {
Configuration configuration;
FileSystem fileSystem;
@Before
public void init() throws URISyntaxException, IOException, InterruptedException {
// 获取hadoop集群configuration对象
configuration = new Configuration();
// 根据configuration获取filesystem对象
fileSystem = FileSystem.get(new URI(