public class HDFSFileStorage extends Object implements IFileStorage
| Modifier and Type | Field and Description |
|---|---|
protected String |
dataFolder |
protected org.apache.hadoop.fs.FileSystem |
fileSystem |
protected String |
url |
| Constructor and Description |
|---|
HDFSFileStorage(String path,
String userName,
String password,
Map options) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
关闭连接
|
String |
combinePaths(String firstFilePath,
String... moreFilePath)
路径连接
|
boolean |
connect()
连接
|
IFileset |
createDirectory(String path,
String name)
在指定目录下创建文件目录
|
boolean |
deleteFile(String filePath)
删除文件或文件目录
|
boolean |
fileExist(String filePath)
文件是否存在
|
IFileset |
getFile(String filePath)
获取指定路径文件或文件目录
|
org.apache.hadoop.fs.Path |
getHdfsPath(String filePath)
获取hdfs Path
|
IFileset |
getParentFile(String filePath)
获取指定路径的父文件
|
String |
getPassword()
获取密码
|
String |
getSeparator()
文件目录分隔符
|
String |
getStorageUrl()
获取文件存储连接地址
|
String |
getType()
存储类型
|
String |
getUserName()
获取用户名
|
List<IFileset> |
listFile(String filePath,
boolean recursion)
指定路径下的文件和文件目录列表
|
InputStream |
openFileStream(String filePath)
打开文件流
|
IFileset |
upload(InputStream srcInputStream,
String destFile,
boolean overwrite)
上传文件流
|
IFileset |
upload(String srcFile,
String destFile,
boolean overwrite)
上传本地文件
|
protected final String url
protected String dataFolder
protected org.apache.hadoop.fs.FileSystem fileSystem
public String getStorageUrl()
IFileStoragegetStorageUrl in interface IFileStoragepublic String getUserName()
IFileStoragegetUserName in interface IFileStoragepublic String getPassword()
IFileStoragegetPassword in interface IFileStoragepublic String getType()
IFileStoragegetType in interface IFileStoragepublic String getSeparator()
IFileStoragegetSeparator in interface IFileStoragepublic boolean connect()
IFileStorageconnect in interface IFileStoragepublic void close()
IFileStorageclose in interface IFileStoragepublic List<IFileset> listFile(String filePath, boolean recursion)
IFileStoragelistFile in interface IFileStoragepublic boolean fileExist(String filePath)
IFileStoragefileExist in interface IFileStoragepublic IFileset getFile(String filePath)
IFileStoragegetFile in interface IFileStoragepublic IFileset getParentFile(String filePath)
IFileStoragegetParentFile in interface IFileStoragepublic boolean deleteFile(String filePath)
IFileStoragedeleteFile in interface IFileStoragepublic IFileset createDirectory(String path, String name)
IFileStoragecreateDirectory in interface IFileStoragepublic String combinePaths(String firstFilePath, String... moreFilePath)
IFileStoragecombinePaths in interface IFileStoragepublic IFileset upload(String srcFile, String destFile, boolean overwrite)
IFileStorageupload in interface IFileStoragesrcFile - 本地源文件路径destFile - 目标文件路径overwrite - 是否覆盖已有文件public IFileset upload(InputStream srcInputStream, String destFile, boolean overwrite)
IFileStorageupload in interface IFileStoragesrcInputStream - 源文件流destFile - 目标文件路径overwrite - 是否覆盖已有文件public InputStream openFileStream(String filePath)
IFileStorageopenFileStream in interface IFileStoragepublic org.apache.hadoop.fs.Path getHdfsPath(String filePath)
filePath - Copyright © 2025. All rights reserved.