Class Builder

java.lang.Object
org.miaixz.bus.shade.safety.Builder

public abstract class Builder extends Object
Jar 工具类,包含I/O,密钥,过滤器的工具方法
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

  • Constructor Details

    • Builder

      public Builder()
  • Method Details

    • readln

      public static byte[] readln(InputStream in) throws IOException
      从输入流中读取一行字节码
      Parameters:
      in - 输入流
      Returns:
      最前面的一行字节码
      Throws:
      IOException - I/O 异常
    • writeln

      public static void writeln(OutputStream out, byte[] line) throws IOException
      往输出流中写入一行字节码
      Parameters:
      out - 输出流
      line - 一行字节码
      Throws:
      IOException - I/O 异常
    • close

      public static void close(Closeable closeable)
      关闭资源,等效于XKit.close(closeable, true);
      Parameters:
      closeable - 资源
    • close

      public static void close(Closeable closeable, boolean quietly) throws IOException
      关闭资源
      Parameters:
      closeable - 资源
      quietly - 是否安静关闭,即捕获到关闭异常时是否忽略
      Throws:
      IOException - 当quietly == false, 时捕获到的I/O异常将会往外抛
    • transfer

      public static long transfer(InputStream in, OutputStream out) throws IOException
      输入流传输到输出流
      Parameters:
      in - 输入流
      out - 输出流
      Returns:
      传输长度
      Throws:
      IOException - I/O 异常
    • transfer

      public static long transfer(Reader reader, Writer writer) throws IOException
      reader传输到writer
      Parameters:
      reader - reader
      writer - writer
      Returns:
      传输长度
      Throws:
      IOException - I/O 异常
    • transfer

      public static long transfer(InputStream in, File file) throws IOException
      输入流传输到文件
      Parameters:
      in - 输入流
      file - 文件
      Returns:
      传输长度
      Throws:
      IOException - I/O 异常
    • transfer

      public static long transfer(Reader reader, File file) throws IOException
      reader传输到文件
      Parameters:
      reader - reader
      file - 文件
      Returns:
      传输长度
      Throws:
      IOException - I/O 异常
    • delete

      public static boolean delete(File file)
      删除文件,如果是目录将不递归删除子文件或目录,等效于delete(file, false);
      Parameters:
      file - 文件/目录
      Returns:
      是否删除成功
    • delete

      public static boolean delete(File file, boolean recursively)
      删除文件,如果是目录将递归删除子文件或目录
      Parameters:
      file - 文件/目录
      recursively - 递归
      Returns:
      是否删除成功
    • key

      public static Key key(String password) throws NoSuchAlgorithmException
      根据密码生成密钥
      Parameters:
      password - 密码
      Returns:
      密钥
      Throws:
      NoSuchAlgorithmException - 没有该密钥算法
    • key

      public static Key key(String algorithm, String password) throws NoSuchAlgorithmException
      根据密码生成密钥
      Parameters:
      algorithm - 密钥算法
      password - 密码
      Returns:
      密钥
      Throws:
      NoSuchAlgorithmException - 没有该密钥算法
    • key

      public static Key key(String algorithm, int keysize, String password) throws NoSuchAlgorithmException
      根据密码生成密钥
      Parameters:
      algorithm - 密钥算法
      keysize - 密钥长度
      password - 密码
      Returns:
      密钥
      Throws:
      NoSuchAlgorithmException - 没有该密钥算法
    • key

      public static Key key(String algorithm, int keysize, int ivsize, String password) throws NoSuchAlgorithmException
      根据密码生成密钥
      Parameters:
      algorithm - 密钥算法
      keysize - 密钥长度
      ivsize - 向量长度
      password - 密码
      Returns:
      密钥
      Throws:
      NoSuchAlgorithmException - 没有该密钥算法
    • retainKey

      public static void retainKey(Key key, Attributes attributes)
    • removeKey

      public static void removeKey(Attributes attributes)
    • all

      public static <E> AllComplex<E> all()
      创建多个子过滤器AND连接的混合过滤器
      Type Parameters:
      E - 对象
      Returns:
      多个子过滤器AND连接的混合过滤器
    • all

      public static <E> AllComplex<E> all(Collection<? extends Complex<E>> filters)
      创建多个子过滤器AND连接的混合过滤器
      Type Parameters:
      E - 对象
      Parameters:
      filters - 子过滤器
      Returns:
      多个子过滤器AND连接的混合过滤器
    • and

      public static <E> AllComplex<E> and()
      创建多个子过滤器AND连接的混合过滤器
      Type Parameters:
      E - 对象
      Returns:
      多个子过滤器AND连接的混合过滤器
    • and

      public static <E> AllComplex<E> and(Collection<? extends Complex<E>> filters)
      创建多个子过滤器AND连接的混合过滤器
      Type Parameters:
      E - 对象
      Parameters:
      filters - 子过滤器
      Returns:
      多个子过滤器AND连接的混合过滤器
    • any

      public static <E> AnyComplex<E> any()
      创建多个子过滤器OR连接的混合过滤器
      Type Parameters:
      E - 对象
      Returns:
      多个子过滤器OR连接的混合过滤器
    • any

      public static <E> AnyComplex<E> any(Collection<? extends Complex<E>> filters)
      创建多个子过滤器OR连接的混合过滤器
      Type Parameters:
      E - 对象
      Parameters:
      filters - 子过滤器
      Returns:
      多个子过滤器OR连接的混合过滤器
    • or

      public static <E> AnyComplex<E> or()
      创建多个子过滤器OR连接的混合过滤器
      Type Parameters:
      E - 对象
      Returns:
      多个子过滤器OR连接的混合过滤器
    • or

      public static <E> AnyComplex<E> or(Collection<? extends Complex<E>> filters)
      创建多个子过滤器OR连接的混合过滤器
      Type Parameters:
      E - 对象
      Parameters:
      filters - 子过滤器
      Returns:
      多个子过滤器OR连接的混合过滤器
    • not

      public static <E> Complex<E> not(Complex<E> filter)
      创建非门逻辑运算过滤器,实际上就是将委派过滤器的过滤结果取反
      Type Parameters:
      E - 对象
      E - 记录类型
      Parameters:
      filter - 委派过滤器
      Returns:
      非门逻辑过滤器
    • isRelative

      public static boolean isRelative(String path)
    • isAbsolute

      public static boolean isAbsolute(String path)
    • absolutize

      public static String absolutize(String path)
    • normalize

      public static String normalize(String path)