java - 如何获取默认的 FileAttributs 以创建路径

标签 java nio

我想用 Files.createFile(path, FileAttributes...) 创建路径

如何获取一组默认的 FileAttributes 以在 Windows 上创建文件?

最佳答案

这是您事业的基本示例。

public static void main(String[] args) throws IOException {

        BasicFileAttributes thisFileBasicAttributes = null;
        Path pathOfThisFile = Paths.get("/myKey.store");
        System.out.println(pathOfThisFile);
        try{
        thisFileBasicAttributes = Files.readAttributes(pathOfThisFile, BasicFileAttributes.class);
        Object fileKeyBasic = thisFileBasicAttributes.fileKey();
        String output = "Basic: " + fileKeyBasic.toString();
        System.out.println(output);
        }
        catch(IOException exception)
        {
            System.err.println("JVM reported an exception, please take a look at" + exception);
        }

    }

关于java - 如何获取默认的 FileAttributs 以创建路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55235935/

相关文章:

java - jXLS jx :image ends with java. lang.IllegalArgumentException: imgBean 值必须包含图像字节

Java Applet 无法清除屏幕上的文本

java - 如何检查列表中的列表是否不为空?

Java NIO : Sending large messages quickly leads to truncated packets and data loss

java - 如何找到 Java BigInteger 的平方根?

java - 如果主机不存在,SocketChannel 的 connect 方法将保持挂起状态

使用 NIO 框架的 Java 程序

java - 有什么方法可以使用 Java NIO/选择器获得读取超时吗?

java - SocketChannel.write 是否等待 TCP ACK?

java - 如何在java中比较两个hashmap?