包
org.apache.hadoop.fs
构造方法
protected FileSystem()
FileSystem是一个抽象类,不能通过new 来创建
通过静态get(Configuration conf)方法获得FileSystem子类的实例
fs.$scheme.impl
org.apache.hadoop.hdfs.DistributedFileSystem
主要子类
LocalFileSystem
本地文件系统
DistributedFileSystem
分布式文件系统
boolean createNewFile(Path f)
不会覆盖已有文件
创建成功返回true,失败返回false
FSDataOutputStream create(Path f)
覆盖已有文件
创建文件并返回输出流
FSDataOutputStream create(Path f,boolean overwrite)
创建文件并返回输出流
FSDataOutputStream create(Path f,boolean overwrite,int buffer)
FSDataOutputStream create(Path f,boolean overwrite,int buffer,short replication,long blockSize)
FSDataInputStream open(Path f)
FSDataInputStream open(Path f, int bufferSize)
返回输入流
如果文件不存在会抛出异常
不指定bufferSize时,会从Configuration中读取io.file.buffer.size,默认为4096字节
FSDataOutputStream append(Path f)
FSDataOutputStream append(Path f, int bufferSize)
块不足64M时,会补足到64M
块达到64M之前,该块不可见,ls看不到该块新增的大小,也无法读取
不能同时多个writer追加同一个文件