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

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

Introduction

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

Prototype

public boolean truncate(Path f, long newLength) throws IOException 

Source Link

Document

Truncate the file in the indicated path to the indicated size.

Usage

From source file:com.mellanox.r4h.DistributedFileSystem.java

License:Apache License

@Override
public boolean truncate(Path f, final long newLength) throws IOException {
    statistics.incrementWriteOps(1);/*ww  w  .  jav a  2 s  .  c  om*/
    Path absF = fixRelativePart(f);
    return new FileSystemLinkResolver<Boolean>() {
        @Override
        public Boolean doCall(final Path p) throws IOException, UnresolvedLinkException {
            return dfs.truncate(getPathName(p), newLength);
        }

        @Override
        public Boolean next(final FileSystem fs, final Path p) throws IOException {
            return fs.truncate(p, newLength);
        }
    }.resolve(this, absF);
}