Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java StorageService在GluonHQ框架上出现错误-如何解决此问题?_Java_Javafx_Gluon Mobile_Javafxports - Fatal编程技术网

Java StorageService在GluonHQ框架上出现错误-如何解决此问题?

Java StorageService在GluonHQ框架上出现错误-如何解决此问题?,java,javafx,gluon-mobile,javafxports,Java,Javafx,Gluon Mobile,Javafxports,通常我在JavaFX中使用FileChooser。非常容易做到这一点。只要调用它,它就会打开一个新窗口,您可以在其中选择您的文件。完成了 但FileChooser在Android和Iphone上不起作用。我必须选择StorageService 但这里的问题是它给出了一个错误: The method orElseThrow(Supplier<? extends X>) in the type Optional<File> is not applicable for the

通常我在JavaFX中使用FileChooser。非常容易做到这一点。只要调用它,它就会打开一个新窗口,您可以在其中选择您的文件。完成了

但FileChooser在Android和Iphone上不起作用。我必须选择StorageService

但这里的问题是它给出了一个错误:

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(FileNotFoundException::new);


值得一读:

这是否打开了一个窗口,我可以在其中选择一个文件?@Heretic这是一个如何解决错误的示例。如何使用orelsethrowd这是否打开了一个窗口,我可以选择一个文件?@Heretic这是一个如何解决错误的例子。如何使用orElseThrow@JoséPereda错误消失,但我无法选择任何文件。我一定是误解了StorageService类的用途了?请从lambda中删除{和},或者确保使用return。如果这是您的意思,则不会显示类似的FileChooser对话框。privateStorage是文件夹根目录,您可以在其中读取和写入文件。在手机上安装应用程序时,这就是您可以执行此操作的沙盒区域。@JoséPereda所以当我运行` File privateStorage=Services.getStorageService.class.flatMapStorageService::getPrivateStorage.Orelestrow->new FileNotFoundException无法访问私有存储。;我可以访问Android/Iphone根文件夹中的´/´?不可以,使用getPrivateStorage可以访问应用程序位置中的给定文件夹。请参见以访问其他位置,如相机文件。还要读一读:关于你在Android上可以做什么和不能做什么。@JoséPereda错误消失了,但我不能选择任何文件。我一定是误解了StorageService类的用途了?请从lambda中删除{和},或者确保使用return。如果这是您的意思,则不会显示类似的FileChooser对话框。privateStorage是文件夹根目录,您可以在其中读取和写入文件。在手机上安装应用程序时,这就是您可以执行此操作的沙盒区域。@JoséPereda所以当我运行` File privateStorage=Services.getStorageService.class.flatMapStorageService::getPrivateStorage.Orelestrow->new FileNotFoundException无法访问私有存储。;我可以访问Android/Iphone根文件夹中的´/´?不可以,使用getPrivateStorage可以访问应用程序位置中的给定文件夹。请参见以访问其他位置,如相机文件。同时阅读以下内容:关于你在Android上可以做什么和不能做什么。
Optional.empty().orElseThrow(()->new FileNotFoundException("Some exception"));
Optional.empty().orElseThrow(() -> {
            return new FileNotFoundException("Some exception");
        });