- 获取用户定义的所有元数据
Path path = Paths.get("E:/1.sql"); UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class); try { for (String name : view.list()) { System.out.println(view.size(name) + " " + name); } } catch (Exception e) { e.printStackTrace(); }
- 自定义元数据
Path path = Paths.get("E:/1.sql"); UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttributeView.class); try { view.write("file.description", Charset.defaultCharset().encode("This file contains private infomation!")); } catch (Exception e) { e.printStackTrace(); }
- 获取自定义元数据
Path path = Paths.get("E:/1.sql"); UserDefinedFileAttributeView view = Files.getFileAttributeView(path, UserDefinedFileAttrib
用户自定义文件的元数据
最新推荐文章于 2024-01-26 07:28:30 发布
本文介绍了如何使用Java NIO2的UserDefinedFileAttributeView来读取、写入和获取用户自定义的文件元数据。通过示例展示了列出元数据名称、写入描述信息以及读取描述信息的过程。
摘要由CSDN通过智能技术生成