Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How can i read file properties

Reply
Thread Tools

How can i read file properties

 
 
Bhaskar Reddy
Guest
Posts: n/a
 
      02-02-2005
Hello,

I want to read the file properties under windows in my Java app. Under
windows you can right click a file and select properties-summary. You can
see properties like Title, Subject,Author etc for every file under windows.
How can I read those 3 properties using Java ? I tried with various search
words in the internet, but unlucky.

Can someone plese point me to something helpful ?

Thanks in advance
Best Regards
Bhaskar Reddy

PS : Reply to newsgroup or to me ""
 
Reply With Quote
 
 
 
 
klynn47@comcast.net
Guest
Posts: n/a
 
      02-02-2005
You can find some of the information with java.io.File

 
Reply With Quote
 
 
 
 
Thomas Fritsch
Guest
Posts: n/a
 
      02-02-2005
Bhaskar Reddy wrote:
> Hello,

Hello!
>
> I want to read the file properties under windows in my Java app. Under
> windows you can right click a file and select properties-summary. You can
> see properties like Title, Subject,Author etc for every file under windows.

I don't agree. In Windows I see (after right-clicking the file-icon, and
selecting "Properties" from the menu) these 3 properties only for very
few file types (*.doc, *.xls, *.ppt). Most other file types (at least
*.txt, *.java, *.gif, *.bat) don't show this information.

> How can I read those 3 properties using Java ? I tried with various search
> words in the internet, but unlucky.

Given the above, this feature is Windows-specific. Other platforms
probably don't have something similar. So chances are small, that a pure
Java solution is possible.

>
> Can someone plese point me to something helpful ?

The only way I see, is programming some some C-functions and calling
them from Java via JNI.
<http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html>

>
> Thanks in advance
> Best Regards
> Bhaskar Reddy
>
> PS : Reply to newsgroup or to me ""



--
"Thomas:Fritsch$ops:de".replace(':','.').replace(' $','@')

 
Reply With Quote
 
Antti S. Brax
Guest
Posts: n/a
 
      02-02-2005
wrote in comp.lang.java.programmer:
> Bhaskar Reddy wrote:
>> I want to read the file properties under windows in my Java app. Under
>> windows you can right click a file and select properties-summary. You can
>> see properties like Title, Subject,Author etc for every file under windows.

> I don't agree. In Windows I see (after right-clicking the file-icon, and
> selecting "Properties" from the menu) these 3 properties only for very
> few file types (*.doc, *.xls, *.ppt). Most other file types (at least
> *.txt, *.java, *.gif, *.bat) don't show this information.
>
>> How can I read those 3 properties using Java ? I tried with various search
>> words in the internet, but unlucky.

> Given the above, this feature is Windows-specific. Other platforms
> probably don't have something similar. So chances are small, that a pure
> Java solution is possible.


Pure java solution is entirely possible. Windows does not just
magically figure out that information. It's all coded in the
file. One just needs to be able to read this metadata from the
file.

--
Antti S. Brax Rullalautailu pitää lapset poissa ladulta
http://www.iki.fi/asb/ http://www.cs.helsinki.fi/u/abrax/hlb/
"Disconnect this cable to shorten, re-connect to lengthen."
-- Instructions on Logitech's USB mouse extension cord.
 
Reply With Quote
 
Steve W. Jackson
Guest
Posts: n/a
 
      02-02-2005
In article <>,
Thomas Fritsch <> wrote:

> Bhaskar Reddy wrote:
> > Hello,

> Hello!
> >
> > I want to read the file properties under windows in my Java app. Under
> > windows you can right click a file and select properties-summary. You can
> > see properties like Title, Subject,Author etc for every file under windows.

> I don't agree. In Windows I see (after right-clicking the file-icon, and
> selecting "Properties" from the menu) these 3 properties only for very
> few file types (*.doc, *.xls, *.ppt). Most other file types (at least
> *.txt, *.java, *.gif, *.bat) don't show this information.
>
> > How can I read those 3 properties using Java ? I tried with various search
> > words in the internet, but unlucky.

> Given the above, this feature is Windows-specific. Other platforms
> probably don't have something similar. So chances are small, that a pure
> Java solution is possible.
>
> >
> > Can someone plese point me to something helpful ?

> The only way I see, is programming some some C-functions and calling
> them from Java via JNI.
> <http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html>
>
> >
> > Thanks in advance
> > Best Regards
> > Bhaskar Reddy
> >
> > PS : Reply to newsgroup or to me ""


I agree with Thomas' response. You may be able to get some of this info
from the javax.swing.filechooser.FileSystemView and
javax.swing.filechooser.FileView classes (descriptions of the file
and/or the file's type). But the remainder is included among the
metadata that is probably either unique to Windows or to the filesystems
used by Windows. So platform-specific code would be needed.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
 
Reply With Quote
 
Steve W. Jackson
Guest
Posts: n/a
 
      02-02-2005
In article <>,
(Antti S. Brax) wrote:

> wrote in comp.lang.java.programmer:
> > Bhaskar Reddy wrote:
> >> I want to read the file properties under windows in my Java app. Under
> >> windows you can right click a file and select properties-summary. You can
> >> see properties like Title, Subject,Author etc for every file under
> >> windows.

> > I don't agree. In Windows I see (after right-clicking the file-icon, and
> > selecting "Properties" from the menu) these 3 properties only for very
> > few file types (*.doc, *.xls, *.ppt). Most other file types (at least
> > *.txt, *.java, *.gif, *.bat) don't show this information.
> >
> >> How can I read those 3 properties using Java ? I tried with various search
> >> words in the internet, but unlucky.

> > Given the above, this feature is Windows-specific. Other platforms
> > probably don't have something similar. So chances are small, that a pure
> > Java solution is possible.

>
> Pure java solution is entirely possible. Windows does not just
> magically figure out that information. It's all coded in the
> file. One just needs to be able to read this metadata from the
> file.


That type of metadata is typically *not* in the file. Instead, it's
stored wherever the filesystem or OS keeps such data, separate from the
file. But even if it were stored in the file itself, the Java classes
related to handling files, filesystems, etc., offer no means of getting
access to such metadata.

= Steve =
--
Steve W. Jackson
Montgomery, Alabama
 
Reply With Quote
 
Ann
Guest
Posts: n/a
 
      02-02-2005

"Antti S. Brax" <> wrote in message
news:...
> wrote in comp.lang.java.programmer:
> > Bhaskar Reddy wrote:
> >> I want to read the file properties under windows in my Java app.

Under
> >> windows you can right click a file and select properties-summary. You

can
> >> see properties like Title, Subject,Author etc for every file under

windows.
> > I don't agree. In Windows I see (after right-clicking the file-icon, and
> > selecting "Properties" from the menu) these 3 properties only for very
> > few file types (*.doc, *.xls, *.ppt). Most other file types (at least
> > *.txt, *.java, *.gif, *.bat) don't show this information.
> >
> >> How can I read those 3 properties using Java ? I tried with various

search
> >> words in the internet, but unlucky.

> > Given the above, this feature is Windows-specific. Other platforms
> > probably don't have something similar. So chances are small, that a pure
> > Java solution is possible.

>
> Pure java solution is entirely possible. Windows does not just
> magically figure out that information. It's all coded in the
> file. One just needs to be able to read this metadata from the
> file.


I just ran a test for a MS Word 2002 file. Examined the properties
and found Title was populated, but Author and Subject were not.
I searched for these strings in the Word file and found the Title
string but not the others. Then I populated Author and Subject.
Another search found these strings too.
Since Windows is supported on the FAT file system, I don't think
the info is stored in the file system.


 
Reply With Quote
 
Bhaskar Reddy
Guest
Posts: n/a
 
      02-03-2005
Bhaskar Reddy <> wrote in
news:ctq6bt$fkq$:

> Hello,
>
> I want to read the file properties under windows in my Java app.
> Under
> windows you can right click a file and select properties-summary. You
> can see properties like Title, Subject,Author etc for every file under
> windows. How can I read those 3 properties using Java ? I tried with
> various search words in the internet, but unlucky.
>
> Can someone plese point me to something helpful ?
>
> Thanks in advance
> Best Regards
> Bhaskar Reddy
>
> PS : Reply to newsgroup or to me ""


Thanks for all those who aired their suggestions and views.

I used POI (free from apache) to read the summary info from DOC and XLS
files. That means this summary info is stored in the file itself.

But I got this problem when I wanted to read this summary info from PDF
and ZIP files. I opened some PDF,ZIP files in Hex editor but could not
find the summary info.

Best Regards
Bhaskar Reddy
 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      02-03-2005
Bhaskar Reddy wrote:

> > I want to read the file properties under windows in my Java app.
> > Under
> > windows you can right click a file and select properties-summary. You
> > can see properties like Title, Subject,Author etc for every file under
> > windows. How can I read those 3 properties using Java ? I tried with
> > various search words in the internet, but unlucky.

[...]
> I used POI (free from apache) to read the summary info from DOC and XLS
> files. That means this summary info is stored in the file itself.
>
> But I got this problem when I wanted to read this summary info from PDF
> and ZIP files. I opened some PDF,ZIP files in Hex editor but could not
> find the summary info.


You can see that it's not /usually/ stored in the file itself by creating an
empty file and setting its properties and summary. That works OK, but the file
size is still zero.

AFAIK, the only correct way to read this data is via MS's COM interfaces. See:
http://msdn.microsoft.com/library/en...setstorage.asp

What looks to me like a good explanation:
http://www.howtodothings.com/showart...sp?article=447

MS also have a sample ActiveX control (with source apparently) that may help:
http://support.microsoft.com/support.../Q224/3/51.asp

You would have to use a COM<->Java bridge (of which there are several
available), or program it yourself in C (via JNI) to make use of the above
possibilities. Another way of getting access to the information would be to
write a small app in C which simply took a filename as parameter and wrote the
file's summary info to stdout -- you could then call that from Java.

BTW, the HowToDoThings article mentions that Office applications store the
summary information in-file rather than in the "normal" additional stream(s).

I came across a rather odd way of getting at the data in pure java. Open a
file called:
realFileName + ":\5SummaryInformation"
(where the \5 is the single character with value 5, not the character '\\'
followed by the digit '5'), and you can read the summary data stream. Of
course you will then have to parse the resulting information, and it's in a
private format (at least, I've not heard of it published), so I can't really
recommend this method as either safe or easy

-- chris



 
Reply With Quote
 
prox99 prox99 is offline
Junior Member
Join Date: Oct 2007
Posts: 1
 
      10-22-2007
Chris, can you post the code to use ":\5SummaryInformation" for file summary information?

Thanks

Ming
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
File.read(fname) vs. File.read(fname,File.size(fname)) Alex Dowad Ruby 4 05-01-2010 08:20 AM
file.read() doesn't read the whole file Sreejith K Python 24 03-24-2009 12:20 PM
Binary data stored in SQL Server: can't read from ASP.NET, *can* read from Access? Doug ASP .Net 3 11-04-2005 07:35 PM
Can not delete file: Can not read from source file or disk. Pundit Computer Support 0 02-28-2005 03:27 AM
How can I read the properties of an Image. Markus Bader Java 2 11-04-2003 03:43 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57