Package com.graphdbapi.file
Interface FileObject
-
public interface FileObject用于IO的文件操作接口
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description BufferedReaderObjectbufferedReader(String path, Charset charsets)BufferedReader流BufferedWriterObjectbufferedWriter(String path, boolean append, Charset charsets)BufferedWriter流default BufferedWriterObjectbufferedWriter(String path, Charset charsets)BufferedWriter流(默认覆盖文件内容)booleancopy(String path, String newPath)复制文件/文件夹booleancreateDir(String path)创建文件夹booleancreateFile(String path)创建文件booleandelete(String path)删除文件/文件夹。 文件:若删除成功,返回true。若删除失败,返回false。 文件夹:若文件夹中有文件,则抛出异常booleandeleteForce(String path)强制删除文件/文件夹。 文件:若删除成功,返回true。若删除失败,返回false。 文件夹:删除所有文件booleanisDir(String path)是否是文件夹booleanisExist(String path)文件/文件夹,是否存在List<String>list(String path)查看文件夹下所有 文件/文件夹 名称列表RandomAccessFileObjectrandomAccessFile(String path, String mode)返回RandomAccessFileObjectvoidreleaseResources()主动释放所有FileObject产生的资源booleansendFile(int affinity, String path, boolean overwrite)指定affinity,同步发送文件。若远端不存在文件夹,默认为远端创建。单机版不可用。Future<Boolean>sendFileAsync(int affinity, String path, boolean overwrite)指定affinity,异步发送文件。若远端不存在文件夹,默认为远端创建。单机版不可用。
-
-
-
Method Detail
-
isExist
boolean isExist(String path) throws GraphDbFileIOException
文件/文件夹,是否存在- Parameters:
path- 文件路径- Returns:
- true存在,false不存在
- Throws:
GraphDbFileIOException- IO异常
-
isDir
boolean isDir(String path) throws GraphDbFileIOException
是否是文件夹- Parameters:
path- 文件路径- Returns:
- true文件夹,false文件
- Throws:
GraphDbFileIOException- IO异常
-
list
List<String> list(String path) throws GraphDbFileIOException
查看文件夹下所有 文件/文件夹 名称列表- Parameters:
path- 文件夹路径- Returns:
- 文件/文件夹 名称列表
- Throws:
GraphDbFileIOException- IO异常
-
createFile
boolean createFile(String path) throws GraphDbFileIOException
创建文件- Parameters:
path- 文件路径- Returns:
- true创建成功,false创建失败
- Throws:
GraphDbFileIOException- IO异常
-
createDir
boolean createDir(String path) throws GraphDbFileIOException
创建文件夹- Parameters:
path- 文件路径- Returns:
- true创建成功,false创建失败
- Throws:
GraphDbFileIOException- IO异常
-
delete
boolean delete(String path) throws GraphDbFileIOException
删除文件/文件夹。 文件:若删除成功,返回true。若删除失败,返回false。 文件夹:若文件夹中有文件,则抛出异常- Parameters:
path- 文件/文件夹路径- Returns:
- true删除成功,false删除失败
- Throws:
GraphDbFileIOException- IO异常
-
deleteForce
boolean deleteForce(String path) throws GraphDbFileIOException
强制删除文件/文件夹。 文件:若删除成功,返回true。若删除失败,返回false。 文件夹:删除所有文件- Parameters:
path- 文件/文件夹路径- Returns:
- true删除成功,false删除失败
- Throws:
GraphDbFileIOException- IO异常
-
copy
boolean copy(String path, String newPath) throws GraphDbFileIOException
复制文件/文件夹- Parameters:
path- 文件/文件夹路径newPath- 需要复制到的路径- Returns:
- true复制成功,false复制失败
- Throws:
GraphDbFileIOException- IO异常
-
sendFile
boolean sendFile(int affinity, String path, boolean overwrite) throws GraphDbFileIOException指定affinity,同步发送文件。若远端不存在文件夹,默认为远端创建。单机版不可用。- Parameters:
affinity- 节点编号path- 文件路径overwrite- 若远端有同盟文件是否覆盖。true覆盖,false跳过- Returns:
- true发送成功,false发送失败
- Throws:
GraphDbFileIOException- IO异常
-
sendFileAsync
Future<Boolean> sendFileAsync(int affinity, String path, boolean overwrite)
指定affinity,异步发送文件。若远端不存在文件夹,默认为远端创建。单机版不可用。- Parameters:
affinity- 节点编号path- 文件路径overwrite- 若远端有同盟文件是否覆盖。true覆盖,false跳过- Returns:
- 异步对象
-
bufferedReader
BufferedReaderObject bufferedReader(String path, Charset charsets) throws GraphDbFileIOException
BufferedReader流- Parameters:
path- 文件路径charsets- 字符编码- Returns:
- BufferedReader流
- Throws:
GraphDbFileIOException- IO异常
-
bufferedWriter
default BufferedWriterObject bufferedWriter(String path, Charset charsets) throws GraphDbFileIOException
BufferedWriter流(默认覆盖文件内容)- Parameters:
path- 文件路径charsets- 字符编码- Returns:
- BufferedWriter流
- Throws:
GraphDbFileIOException- IO异常
-
bufferedWriter
BufferedWriterObject bufferedWriter(String path, boolean append, Charset charsets) throws GraphDbFileIOException
BufferedWriter流- Parameters:
path- 文件路径append- 写入时追加(true)或覆盖(false)charsets- 字符编码- Returns:
- BufferedWriter流
- Throws:
GraphDbFileIOException- IO异常
-
randomAccessFile
RandomAccessFileObject randomAccessFile(String path, String mode) throws GraphDbFileIOException
返回RandomAccessFileObject- Parameters:
path- 文件路径mode- 读写模式(r:只读 rw:读、写 rws:读、写同步,刷新内容、元数据 rwd:读、写同步,刷新内容)- Returns:
- BufferedReader流
- Throws:
GraphDbFileIOException- IO异常
-
releaseResources
void releaseResources() throws GraphDbFileIOException主动释放所有FileObject产生的资源- Throws:
GraphDbFileIOException- IO异常
-
-