1、配置集群(hdfs-site.xml),必须配置才可以
<property>
<name>dfs.support.append</name>
<value>true</value>
</property>
public static void Addline() throws IOException, URISyntaxException {
// HDFS向文件夹中 追加 一行内容
FileSystem fs = FileSystem.get(new URI("hdfs://192.168.10.111:8020"), new Configuration());
FSDataOutputStream append = fs.append(new Path("/Test001/abc.txt"));
append.write("222222".getBytes());
append.close();
fs.close();
}