通常我一直在JavaFX中使用FileChooser。 super 容易做到这一点。只需调用它,它就会打开一个新窗口,您可以在其中选择文件。完成!
但是 FileChooser
不适用于 Android 和 Iphone。我必须选择 StorageService
而不是
https://docs.gluonhq.com/charm/javadoc/5.0.1/com/gluonhq/charm/down/plugins/StorageService.html
File privateStorage = Services.get(StorageService.class)
.flatMap(StorageService::getPrivateStorage)
.orElseThrow(() -> {
new FileNotFoundException("Could not access private storage.");
});
但是这里的问题是它给出了一个错误:
The method orElseThrow(Supplier<? extends X>) in the type Optional<File> is not applicable for the arguments (() -> {})
那么我该如何解决这个问题呢?
最佳答案
你可以这样做:
Optional.empty().orElseThrow(FileNotFoundException::new);
或
Optional.empty().orElseThrow(()->new FileNotFoundException("Some exception"));
或
Optional.empty().orElseThrow(() -> {
return new FileNotFoundException("Some exception");
});
关于java - StorageService 在 GluonHQ 框架上出现错误 - 如何解决此问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57441232/