Chinaunix首页 | 论坛 | 博客
  • 博客访问: 404753
  • 博文数量: 22
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1712
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-09 10:51
文章分类

全部博文(22)

文章存档

2016年(3)

2015年(6)

2014年(1)

2013年(12)

我的朋友

分类: HADOOP

2013-09-09 17:13:19

写文件:

 

 

[java] view plaincopy
  1. //指定configuration   
  2. Configuration config = new Configuration();   
  3. String time = String.valueOf(end-start);   
  4. FileSystem fs = FileSystem.get(URI.create("ListStatus"),config);   
  5. OutputStream out = fs.create(new Path("/user/student/data/time.txt")); out.write(time.getBytes());   


 

读文件:

 


[java] view plaincopy
  1. //指定configuration   
  2. Configuration config = new Configuration();   
  3. //定义一个DataInputStream   
  4. FSDataInputStream indic = null;   
  5. ArrayList dictionary = new ArrayList();   
  6. FileSystem fs = FileSystem.get(URI.create("ListStatus"),config);   
  7. indic = fs.open(new Path("dic/xxx.txt"));   
  8. String t = indic.readLine();   
  9. while (t != null) {   
  10.      dictionary.add(t);   
  11.      t = indic.readLine();   
  12. }  


阅读(6403) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~