标签:util 读取 bis short void mave input hdf throw
1 public class TestRead { 2 @Test 3 public void readTest() throws Exception { 4 Configuration conf = new Configuration(); 5 FileSystem fs = FileSystem.get(conf); 6 FSDataInputStream fis = fs.open(new Path("hdfs://s201:8020/user/centos/hadoop/hello.txt")); 7 IOUtils.copyBytes(fis, System.out, 1024); 8 IOUtils.closeStream(fis); 9 10 } 11 12 @Test 13 public void writeTest() throws Exception { 14 Configuration conf = new Configuration(); 15 FileSystem fs = FileSystem.get(conf); 16 FSDataOutputStream fos = fs.create(new Path("hdfs://s201:8020/user/centos/hadoop/3.txt"),true,1024,(short)2,512); 17 ByteArrayInputStream bis=new ByteArrayInputStream("who am i".getBytes()); 18 IOUtils.copyBytes(bis,fos,1024); 19 IOUtils.closeStream(fos); 20 21 } 22 }
标签:util 读取 bis short void mave input hdf throw
原文地址:http://www.cnblogs.com/yihaifutai/p/6896607.html