file - check if a folder is readable in Java 1.6 -


i trying check if folder readable in java 1.6 following 2 manner:

1) using canread method of file class. it's readable time (canread() return true):

final file folder = new file("file.xml"); if(folder.canread()){    // file readable }else{    // file not readable!! } 

2) using filepermission class , catch exception. catchs exception time (when folder readable or not):

try {    filepermission filepermission = new filepermission(folder.getabsolutepath(), "read"); accesscontroller.checkpermission(filepermission);  // file readable   } catch (accesscontrolexception pace) {  // file not readable !! }  

i have found there issue between microsoft windows os , java 1.6 case.

bug: http://bugs.java.com/bugdatabase/view_bug.do?bug_id=6203387

have solution?

this quick , dirty,

file dir = new file("foo"); if (dir.exists()) {    if (dir.listfiles() == null) {       // directory not readable    } } 

all io errors handled inside of listfiles().


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -