Example usage for org.apache.hadoop.hdfs DistributedFileSystem append

List of usage examples for org.apache.hadoop.hdfs DistributedFileSystem append

Introduction

In this page you can find the example usage for org.apache.hadoop.hdfs DistributedFileSystem append.

Prototype

public FSDataOutputStream append(Path f) throws IOException 

Source Link

Document

Append to an existing file (optional operation).

Usage

From source file:backup.integration.MiniClusterTestBase.java

License:Apache License

private void writeFile(DistributedFileSystem fileSystem, Path path) throws IOException, InterruptedException {
    try (FSDataOutputStream outputStream = fileSystem.create(path)) {
        for (int i = 0; i < 10; i++) {
            outputStream.write("abc".getBytes());
            outputStream.hsync();/*from  ww w. j  a  v a 2 s.c  o  m*/
            Thread.sleep(50);
        }
    }
    try (FSDataOutputStream outputStream = fileSystem.append(path)) {
        for (int i = 0; i < 10; i++) {
            outputStream.write("abc".getBytes());
            outputStream.hsync();
            Thread.sleep(50);
        }
    }
}