Reputation: 5452
I'm trying to read some basic file attributes, i.e. is file readable, writeable etc... I've been baning my head reading the java tutorial. Seems fairly easy only my eclipse doesn't recognize any of the interfaces/methods that are in the tutorial.
Also I found this Files class that also doesn't work. I am using ubuntu but wasn't able to tell what version of JDK I am using. Also I didn't see anywhere in the documentation that those methods are new. Any ideas about why can't I use them?
Upvotes: 3
Views: 2778
Reputation: 72294
If you just want to read basic attributes and you're using Java 6 (or above) just use canRead()
, canWrite()
and canExecute()
. All are on the basic File class.
The doc you link to there is for JDK7 which isn't yet released (due late July this year.) So you probably don't want to be looking at that unless you're specifically developing for it in advance!
UPDATE: Java 7 is of course now released.
Upvotes: 3
Reputation: 15363
For your version at the command line try java -version otherwise I'd go with berry's suggestion of using the java.io.* stuff. If you're really hard up you can execute a bash command(http://ubuntuforums.org/archive/index.php/t-319735.html) and parse the output but then you are seriously platform dependent.
Upvotes: 0