Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getting FileInformation : title, categorie  RSS feed

 
simon worx
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,
i want to read the additional Fileinformation which can be added to a file with windows. like the title, categorie, author, comments and so on. And i want to read these information out of my java source.
can anybody tell me how i can realize that??
the infos i mean are on a seperate detail-tab in the file-information window of each file.

thanks a lot!

simon
 
Prashant Sehgal
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a first remedy, explore the methods in the java.io.File class. getName(), getAbsplutePath() and some methods in the java.nio.FileChannel class like getSize()...as in etc will give you quite a bit of information on the file.

For additional information, in case of windows, you'll probably have to make some Windows System calls on the file (using the Runtime and Process classes) and read the output from that. You can get information such as "author" etc form there. Google on "FileSystemObject VB" and you may find some utility that's already doing this.

Else you can go to you DOS prompt and type "help". When you press enter, you'll see all the DOS commands supported for your DOS flavor. See how many of them work on files. Call them (using the Runtime and Process classes) on the file and parse the output for all the information you need.

On UNIX, it's much simpler to do all this. Just take a look at all the options of "ls". For example, on parsing the output from "ls -lcp testfile.txt" will give you the file permissions, author, group, modified date etc.

[ September 22, 2004: Message edited by: Prashant Sehgal ]

[ September 22, 2004: Message edited by: Prashant Sehgal ]
[ September 22, 2004: Message edited by: Prashant Sehgal ]
 
simon worx
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thank's for your post,
1. i don't have the FileChannel class?!? maybe i have an old version of the java.io package?! anyway, there's would be no possibility to get the author and title u said...
2. u told me to use Runtime and Process classes, do u mean from the java.lang package or what?
3. u told me to google vor "FileSystemObject VB" i know what that is, but this is VB specific, and i HAVE to do it with java, no way...

any other helping words??

thank's

simon
 
Prashant Sehgal
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey thank's for your post,
1. i don't have the FileChannel class?!? maybe i have an old version of the java.io package?! anyway, there's would be no possibility to get the author and title u said...
>> As of j2sdk 1.4.x, there is a new package called java.nio. The FileChannel class can be found there.

2. u told me to use Runtime and Process classes, do u mean from the java.lang package or what?
>> Yup.

3. u told me to google vor "FileSystemObject VB" i know what that is, but this is VB specific, and i HAVE to do it with java, no way...
>> For file information that is Windows specific, you need windows specific system calls. For this you need a windows based command line utility (or some options in existing DOS commandds) that give you this info. In either case, you'ld have to make these calls by using the Runtime and Process classes.


any other helping words??

thank's

simon
[ September 24, 2004: Message edited by: Prashant Sehgal ]
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!