- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有这个方法,它应该返回一个 OberservableList,用于 JavaFX ListView,其中包含 currentUserPath
中的文件名。 (默认初始化为 System.getProperty("user.home")
)。
public ObservableList<String> getUserItems(){
ObservableList<String> fileList = FXCollections.observableArrayList();
try {
Files.walk(Paths.get(currentUserPath)).forEach(filePath -> {
if (Files.isRegularFile(filePath)) {
fileList.add(filePath.getFileName().toString());
}
});
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return fileList;
}
不幸的是,我收到了 AccessDeniedException
调用此方法后。这是堆栈跟踪:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1774)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(FXMLLoader.java:1657)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:86)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:49)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Node.fireEvent(Node.java:8411)
at javafx.scene.control.Button.fire(Button.java:185)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(ButtonBehavior.java:182)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:96)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(BehaviorSkinBase.java:89)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(CompositeEventHandler.java:218)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(CompositeEventHandler.java:80)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:238)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(EventHandlerManager.java:191)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(CompositeEventDispatcher.java:59)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:58)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(BasicEventDispatcher.java:56)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(EventDispatchChainImpl.java:114)
at com.sun.javafx.event.EventUtil.fireEventImpl(EventUtil.java:74)
at com.sun.javafx.event.EventUtil.fireEvent(EventUtil.java:54)
at javafx.event.Event.fireEvent(Event.java:198)
at javafx.scene.Scene$MouseHandler.process(Scene.java:3757)
at javafx.scene.Scene$MouseHandler.access$1500(Scene.java:3485)
at javafx.scene.Scene.impl_processMouseEvent(Scene.java:1762)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Scene.java:2494)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:380)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(GlassViewEventHandler.java:294)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.lambda$handleMouseEvent$354(GlassViewEventHandler.java:416)
at com.sun.javafx.tk.quantum.QuantumToolkit.runWithoutRenderLock(QuantumToolkit.java:389)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(GlassViewEventHandler.java:415)
at com.sun.glass.ui.View.handleMouseEvent(View.java:555)
at com.sun.glass.ui.View.notifyMouse(View.java:937)
at com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
at com.sun.glass.ui.gtk.GtkApplication.lambda$null$49(GtkApplication.java:139)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1769)
... 48 more
Caused by: java.io.UncheckedIOException: java.nio.file.AccessDeniedException: /home/adam/.gconf/apps/gedit-2
at java.nio.file.FileTreeIterator.fetchNextIfNeeded(FileTreeIterator.java:88)
at java.nio.file.FileTreeIterator.hasNext(FileTreeIterator.java:104)
at java.util.Iterator.forEachRemaining(Iterator.java:115)
at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
at application.FTPDownload.getUserItems(FTPDownload.java:147)
at application.FTPController.handleConnectButtonAction(FTPController.java:23)
... 58 more
Caused by: java.nio.file.AccessDeniedException: /home/adam/.gconf/apps/gedit-2
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newDirectoryStream(UnixFileSystemProvider.java:427)
at java.nio.file.Files.newDirectoryStream(Files.java:457)
at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:300)
at java.nio.file.FileTreeWalker.next(FileTreeWalker.java:372)
at java.nio.file.FileTreeIterator.fetchNextIfNeeded(FileTreeIterator.java:84)
... 69 more
谁能告诉我为什么我可能会遇到这个异常?任何帮助将不胜感激。
最佳答案
该异常的 javadoc 说:
"[This is a] checked exception [that is] thrown when a file system operation is denied, typically due to a file permission or other access check."
因此最可能的解释是运行应用程序的帐户没有读取“/home/adam/.gconf/apps/gedit-2”目录的权限。
关于java - 读取用户文件系统返回 AccessDeniedException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37510979/
这个问题已经有答案了: Avoid Java 8 Files.walk(..) termination cause of ( java.nio.file.AccessDeniedException )
我正在尝试删除一个文件,然后重新创建它。首先,我检查该文件是否已存在,如果存在,则将其删除。然后我尝试在同一位置创建一个具有相同名称的新文件。当我这样做时,我收到此错误: java.nio.file.
这是尝试在我的 usb 连接的 android 设备上运行/测试应用程序后我的 android studio 控制台收到的错误 错误:任务 ':app:mockableAndroidJar' 执行失败
我正在创建简单的对象序列化,并且BufferedOutputStream的创建引发了异常AccessDeniedException。这是代码: Path filePath = Paths.get("c
我想访问我的网络应用程序之外的静态资源,这样它们就不会在每次重新部署时被破坏,但我似乎无法获取它们 我有一个 servlet,旨在通过 FileOutputStream 提供这些图像,但当我将其部署到
描述: 我在 Java 8 中创建了一个 ZIP 文件,并尝试将一个目录及其所有子文件和目录复制到该 zip 文件中。 Path directory = Paths.get("P:\Java\T
在我的 Spring Boot Web 应用程序中,只要用户没有必要的权限,我就会在我的业务代码中抛出 org.springframework.security.access.AccessDenied
我有 2 个服务:RecentRecordService 和 BookService。 @Service public class RecentRecordService { @Transac
我正在使用 Swift AWS Mobile Hub Helper 构建我的 iOS 应用程序并连接到我的 DynamoDB 数据库。我可以看到,在使用 Facebook SignInProvider
我使用这个自定义错误处理程序: @Component public class OAuth2AuthenticationEntryPoint implements AuthenticationEntr
使用AWS CLI aws --version aws-cli/1.11.21 Python/2.7.12 Darwin/15.3.0 botocore/1.4.78 如https://github.
解决完所有authentication related problems后在我的第一个 Spring Web 应用程序中,我现在陷入了授权的困境。 使用@Secured注释进行配置非常简单,所以我认为
我在 Spring Security 中使用角色层次结构。 ROLE_USER > ROLE_GUEST
我编写了一个小方法,用于告诉我应用程序的另一个实例是否已在运行。我知道有很多方法可以查明另一个实例是否正在运行,但我选择了这个。我正在创建一个空文件并在应用程序实例期间保持锁定状态。如果另一个实例正在
我是 amazon Dynamo DB 的新手。我收到访问被拒绝的异常。 请帮我解决这个问题。 错误: User: arn:aws:sts::xx:assumed-role/Cognito_Sampl
我在解决运行在 Tomcat 6.0 上的 Java Servlet 的权限问题时遇到了问题 当我尝试操作存储在网络共享上的文件时遇到 AccessDeniedException。 这是堆栈跟踪: j
我目前正在尝试将 GWT 网络应用程序部署到 tomcat 实例,但该程序未正确运行。仔细检查 tomcat 日志后,Tomcat 似乎遇到了 AccessDeniedException。 SEVER
我想使用此代码读取文件内容: String content = new String(Files.readAllBytes(Paths.get("/sys/devices/virtual/dmi/id
我是 AWS 新手。我有一个用户帐户和两个角色,一个用于生产,一个用于测试。 通常我会登录我的帐户并切换到产品角色来运行一些简单的选择查询。 现在我想通过 PyAthena 在 Python 中本地使
首先让我说,对于我的场景,访问应该被拒绝。内置 Spring Boot 和 Spring Security 4。我允许任何人连接到 websocket 并订阅一个主题,但我确保能够使用以下 web 套
我是一名优秀的程序员,十分优秀!