You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Uma Maheswara Rao G <ma...@huawei.com> on 2011/12/16 17:51:44 UTC
RE: how read a file in HDFS?
Yes you can use utility methods from IOUtils
ex:
FileOutputStream fo = new FileOutputStream (file);
IOUtils.copyBytes(fs.open(fileName), fo, 1024, true);
here fs is DFS stream.
other option is, you can make use of FileSystem apis.
EX:
FileSystem fs=new DistributedFileSystem();
fs.initialize(new URI("namenode_uri"), conf);
fs.copyToLocalFile(new Path(SRC_PATH),new Path(DST_PATH));
here you can give source path as DFS path and dst path local fileststem path.
hope it helps.
Regards,
Uma
________________________________
From: Pedro Costa [psdc1978@gmail.com]
Sent: Friday, December 16, 2011 9:27 PM
To: mapreduce-user
Subject: Fwd: how read a file in HDFS?
Hi,
I want to read a file that has 100MB of size and it is in the HDFS. How should I do it? Is it with IOUtils.readFully?
Can anyone give me an example?
--
Thanks,
--
Thanks,