public class HDFSDemo {

    private FileSystem fs = null;
@Before
public void init() throws IOException, URISyntaxException, InterruptedException{
fs = FileSystem.get(new URI("hdfs://localhost:9000"), new Configuration());
}
@Test
//递归删除文件或者文件夹
public void testDel() throws IllegalArgumentException, IOException{
boolean flag = fs.delete(new Path("/test"),true);
System.out.println(flag);
}
@Test
//创建目录
public void testMkdir() throws IllegalArgumentException, IOException{
boolean flag = fs.mkdirs(new Path("/Google3Papers"));
System.out.println(flag);
}
@Test
//上传文件
public void testUpload() throws IllegalArgumentException, IOException{
FSDataOutputStream out = fs.create(new Path("/Google3Papers/Google-Bigtable1.0.pdf"));
FileInputStream in = new FileInputStream(new File("/Users/fengmingyue/Desktop/Google-Bigtable1.0.pdf"));
IOUtils.copyBytes(in, out, 2048, true);
}
@Test
//下载文件
public void testDownload() throws IllegalArgumentException, IOException{
InputStream in = fs.open(new Path("/test"));
FileOutputStream out = new FileOutputStream(new File("/Users/fengmingyue/Desktop/ttt"));
IOUtils.copyBytes(in, out, 2048, true);
}
}

最新文章

  1. 修改远程桌面连接端口3389,RDP-Tcp的portnumber要用十六进制修改
  2. SQLSERVER如何查看索引缺失
  3. TeamTalk源码分析之login_server
  4. js实现拖拽
  5. Configure SSL for SharePoint 2013
  6. 基于网页内容数据采集 PHP开发学习笔记
  7. 线程入门之实现Runnable接口和继承Thread类
  8. [Cocos2d-x for WP8学习笔记] HelloWorld结构分析
  9. ACM - ICPC World Finals 2013 B Hey, Better Bettor
  10. PythonCrawl自学日志(3)
  11. C语言中如何使用宏
  12. nginx源代码分析--高性能server开发 常见的流程模型
  13. Java 内存架构
  14. Nicholas C. Zakas谈怎样才能成为优秀的前端工程师
  15. 安卓图表引擎AChartEngine(四) - 源码示例 嵌入Acitivity中的折线图
  16. IntelliJ IDEA 创建 Maven简单项目
  17. vue单文件组件实例1:简单单文件组件
  18. [Java] 方法 -- 繼承關係
  19. 嵌入式linux教程
  20. goto语句引起的crosses initialization of XXX

热门文章

  1. 【代码笔记】iOS-cell自动变化大小
  2. 【java错误】System.out.println()出错
  3. cocos2d-x学习网站
  4. 一步一步 Pwn RouterOS之exploit构造
  5. 跨域调用报表展现页面的flash打印方法
  6. linux rpm命令之查询包安装与否、包详细信息、包安装位置、文件属于哪个包、包依赖
  7. linux 目录操作命令 mkdir、rmdir、cd -、cp、scp、mv、rm
  8. lsnrctl 与 tnsnames.ora 的联系
  9. Centos 使用C++11 编译
  10. 风险管理,未雨绸缪——《代码之殇》读书笔记II