【发布时间】:2021-09-29 20:04:14
【问题描述】:
我已经尝试了三个不同的项目并对其进行了测试,但它们都不起作用..
- 尝试写入文件时出现“java.nio.file.NoSuchFileException”;
List<String> contents = Arrays.asList("Hey, there!", "What's up?");
Files.write(Paths.get("C://Users//*****//Documents//NetBeansProjects//SelTest//output.txt"), contents);
Java 输出:
Exception in thread "main" java.nio.file.NoSuchFileException: C:\Users\*****\Documents\NetBeansProjects\SelTest\output.txt
我已经创建并准备好了 output.txt 文件。
还有一个错误,尝试从 BufferedImage 保存图像时,我的代码已成功执行,但没有创建任何内容?
ImageIO.write(outputImage, "jpg", new File("C:\\Users\\****\\Documents\\NetBeansProjects\\SelTest\\love.jpg"));
我可以将 BufferedImage 显示为标签,它渲染得很好,但是 ImageIO.write,显示没有成功执行错误代码但没有创建文件!
我今天尝试的最后一件事是阅读 Selenium 驱动程序。我已经很好地设置了驱动程序路径并且它在正确的位置但仍然没有得到驱动程序。
System.setProperty("webdriver.edge.driver", "C:\\Users\\*****\\Documents\\NetBeansProjects\\SelTest\\msedgedriver.exe");
WebDriver driver = new EdgeDriver();
Java 输出
Exception in thread "main" java.lang.IllegalStateException: The driver executable does not exist: C:\Users\*****\Documents\NetBeansProjects\SelTest\msedgedriver.exe
at com.google.common.base.Preconditions.checkState(Preconditions.java:585)
我正在使用 Apache NetBeans IDE 12 和我的 Java:
openjdk version "11.0.11" 2021-04-20 LTS
OpenJDK Runtime Environment (build 11.0.11+9-LTS)
OpenJDK 64-Bit Server VM (build 11.0.11+9-LTS, mixed mode)
【问题讨论】:
标签: java windows selenium io openjdk-11