X11ClientHandler.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package com.primeton.damp.fileclient;
  2. import java.io.Closeable;
  3. import java.io.IOException;
  4. import java.io.OutputStream;
  5. import java.nio.file.Path;
  6. import java.util.List;
  7. import java.util.Properties;
  8. /**
  9. *
  10. *
  11. * X11 连接。 可选的子实现:FTP, SFTP 协议。使用完成请关闭 close
  12. *
  13. *
  14. * Created by 59850 on 2019/3/28.
  15. */
  16. public interface X11ClientHandler extends Closeable {
  17. /**
  18. * 根据 配置参数,重新连接 ftp
  19. * @param params
  20. * @throws IOException
  21. */
  22. public void reconnect(Properties params) throws IOException;
  23. /**
  24. * 写入文件,输出流
  25. * @param file 文件地址,绝对路径
  26. * @param overwrite 是否覆盖写入
  27. * @return
  28. * @throws IOException
  29. */
  30. public OutputStream writeFile(String file, boolean overwrite) throws IOException;
  31. /**
  32. * 创建目录,, 如 Linux: mkdir /dir/path, 如 /dir 不存在则报错
  33. * @param path
  34. * @return
  35. */
  36. public boolean mkdir(String path);
  37. /**
  38. * 创建目录,多层级创建, 如 Linux: mkdir -p /dir/path
  39. * @param path
  40. * @return
  41. */
  42. public boolean mkdirs(String path);
  43. /**
  44. * 获取子目录或子文件
  45. * @param ftpPath
  46. * @return
  47. */
  48. public List<Path> getChildren(String ftpPath);
  49. /**
  50. * 判断是否存在该路径,无论文件夹或者文件
  51. * @param path
  52. * @return 返回 true 则存在
  53. */
  54. public boolean exists(String path);
  55. /**
  56. * 判断是否存在该文件夹
  57. * @param path 文件夹地址
  58. * @return 返回 true 则存在
  59. */
  60. public boolean existsDir(String path);
  61. /**
  62. * 判断是否存在该文件
  63. * @param path 文件地址
  64. * @return 返回 true 则存在
  65. */
  66. public boolean existsFile(String path);
  67. }