From 788f28b6798df10e199618cc08d90284a1ee15ad Mon Sep 17 00:00:00 2001 From: Jakob Homan Date: Tue, 6 Dec 2011 06:35:02 +0000 Subject: [PATCH] HADOOP-7886. Add toString to FileStatus. Contributed by SreeHari. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1210793 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 2 ++ .../java/org/apache/hadoop/fs/FileStatus.java | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 10f5f7e21f5..6eec661d150 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -72,6 +72,8 @@ Trunk (unreleased changes) HADOOP-7876. Provided access to encoded key in DelegationKey for use in protobuf based RPCs. (suresh) + HADOOP-7886. Add toString to FileStatus. (SreeHari via jghoman) + BUGS HADOOP-7606. Upgrade Jackson to version 1.7.1 to match the version required diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java index b37fd93add3..f4492e2f235 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileStatus.java @@ -331,4 +331,23 @@ public class FileStatus implements Writable, Comparable { public int hashCode() { return getPath().hashCode(); } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(getClass().getSimpleName()); + sb.append("{"); + sb.append("path=" + path); + sb.append("; isDirectory=" + isdir); + if(!isDirectory()){ + sb.append("; length=" + length); + sb.append("; replication=" + block_replication); + sb.append("; blocksize=" + blocksize); + } + sb.append("; owner=" + owner); + sb.append("; group=" + group); + sb.append("; permission=" + permission); + sb.append("}"); + return sb.toString(); + } }