Example usage for org.apache.hadoop.fs FileSystem append

List of usage examples for org.apache.hadoop.fs FileSystem append

Introduction

In this page you can find the example usage for org.apache.hadoop.fs FileSystem append.

Prototype

public FSDataOutputStream append(Path f) throws IOException 

Source Link

Document

Append to an existing file (optional operation).

Usage

From source file:org.trustedanalytics.utils.hdfs.HdfsConfigFactoryTest.java

License:Apache License

private void testAppendFunction(FileSystem fs, LocatedFileStatus remoteFile) throws IOException {
    try (OutputStream out = fs.append(remoteFile.getPath())) {
        out.write(APPEND_TEXT.getBytes());
    }//from  www .j  a v  a 2 s.  c om

    try (InputStreamReader in = new InputStreamReader(fs.open(remoteFile.getPath()));
            BufferedReader br = new BufferedReader(in)) {
        String content = br.readLine();
        assert br.readLine() == null;
        assertThat("File was not appended properly", content, containsString(APPEND_TEXT));
    }
}