java.io.FileNotFoundException :(访问被拒绝) [英] java.io.FileNotFoundException: (Access is denied)
本文介绍了java.io.FileNotFoundException :(访问被拒绝)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试读取文件夹中的文件,但是当我运行该程序时,它会抛出此异常。我也尝试过其他一些文件夹。抛出相同的异常。
I am trying to read the files inside a folder, but when I run the program it throws this exception. I tried with some other folders also. It throws the same exception.
Exception in thread "main" java.io.FileNotFoundException: C:\backup (Access is denied)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
推荐答案
您无法打开和阅读目录,请使用 isFile()
和 isDirectory()
区分文件和文件夹的方法。您可以使用 list()
和 listFiles()
方法获取文件夹的内容(对于文件名和<$ c)分别为$ c>文件 s)您还可以指定一个过滤器,用于选择列出的文件子集。
You cannot open and read a directory, use the isFile()
and isDirectory()
methods to distinguish between files and folders. You can get the contents of folders using the list()
and listFiles()
methods (for filenames and File
s respectively) you can also specify a filter that selects a subset of files listed.
这篇关于java.io.FileNotFoundException :(访问被拒绝)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文