arun abimaniyu
arun abimaniyu

Reputation: 167

Is it possible to append the data to hdfs using java

I am having one tab delimited file in hdfs. I need to append the user input to that delimited file in hdfs using Java. I don't know how to implement this. If any one tell me the logic it will be very useful for me.

Upvotes: 1

Views: 66

Answers (2)

Thanga
Thanga

Reputation: 8161

The class org.apache.hadoop.dfs.DistributedFileSystem has a method append which returns a stream object FSDataOutputStream in which you can write with out.write. This will make your job done. Refer for doc here http://archive.cloudera.com/cdh/2/hadoop-0.18.3+76.2/api/org/apache/hadoop/dfs/DistributedFileSystem.html#append%28org.apache.hadoop.fs.Path,%20int,%20org.apache.hadoop.util.Progressable%29

Upvotes: 2

Suresh Ram
Suresh Ram

Reputation: 1034

Please add below property in hdfs-site.xml and try

<property>
  <name>dfs.support.append</name>
  <value>true</value>
  <description>
    Does HDFS allow appends to files?
  </description>
</property>

Regards, mar

Upvotes: 1

Related Questions