HDFS——如何获取文件的属性信息
来源:互联网 发布:小gps数据导不出 编辑:程序博客网 时间:2024/06/08 15:28
可以用bin/hadoop fs -ls 来读取HDFS上的文件属性信息。
也可以采用HDFS的API来读取。如下:
import java.net.URI;import org.apache.hadoop.conf.Configuration;import org.apache.hadoop.fs.FileSystem;import org.apache.hadoop.fs.Path;import org.apache.hadoop.fs.FileStatus;public class FileInfo{ public static void main(String[] args) throws Exception { if(args.length != 1){ System.out.println("Usage FileInfo <target>"); System.exit(1); } Configuration conf = new Configuration(); FileSystem hdfs = FileSystem.get(URI.create(args[0]),conf); FileStatus fs = hdfs.getFileStatus(new Path(args[0])); System.out.println("path: "+fs.getPath()); System.out.println("length: "+fs.getLen()); System.out.println("modify time: "+fs.getModificationTime()); System.out.println("owner: "+fs.getOwner()); System.out.println("replication: "+fs.getReplication()); System.out.println("blockSize: "+fs.getBlockSize()); System.out.println("group: "+fs.getGroup()); System.out.println("permission: "+fs.getPermission().toString()); }}
0 0
- HDFS——如何获取文件的属性信息
- 【java常见问题】——如何获取文件的属性信息?
- java流学习-如何获取文件的属性信息
- 如何获取GDI对象的属性信息
- 三、获取文件的属性信息
- 如何获取文件的摘要信息!!!!
- Spring如何获取Properties文件的信息
- HDFS——如何列出目录下的所有文件
- HDFS——如何将文件复制到HDFS
- HDFS——如何将文件从HDFS上删除
- HDFS——如何从HDFS上读取文件内容
- 获取文件的属性信息及其操作函数
- eclipse上hdfs的javaapi调用文件或者获取节点信息没有权限
- 如何获取多媒体文件信息
- 图像属性信息的获取
- 图像属性信息的获取
- 获取照片的属性信息
- 获取照片的属性信息
- Environment variable: "PATH" - This test checks whether the length of the environment variable "PATH
- getAttributedStringHeightWithString
- What are some lesser known but useful Unix commands?
- cocos2d-x动画加速与减速
- 统计
- HDFS——如何获取文件的属性信息
- 使用vs2010编译项目时出现COFF错误的解决方案
- HDU1026
- Linux下查看.so和可执行文件是否debug编译
- 一般数据库增量更新方法--假增量
- QT滚动字幕代码(包括中英文截取)
- 产生了越来越多的移动端客户流量
- 操作List View(添加tooltip到List View的列头)
- ios 获取当前时间汇总