How can i read file properties

Discussion in 'Java' started by Bhaskar Reddy, Feb 2, 2005.

  1. 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 ""
     
    Bhaskar Reddy, Feb 2, 2005
    #1
    1. Advertising

  2. Bhaskar Reddy

    Guest

    You can find some of the information with java.io.File
     
    , Feb 2, 2005
    #2
    1. Advertising

  3. 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('$','@')
     
    Thomas Fritsch, Feb 2, 2005
    #3
  4. 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.
     
    Antti S. Brax, Feb 2, 2005
    #4
  5. 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
     
    Steve W. Jackson, Feb 2, 2005
    #5
  6. 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
     
    Steve W. Jackson, Feb 2, 2005
    #6
  7. Bhaskar Reddy

    Ann Guest

    "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.
     
    Ann, Feb 2, 2005
    #7
  8. 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
     
    Bhaskar Reddy, Feb 3, 2005
    #8
  9. Bhaskar Reddy

    Chris Uppal Guest

    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-us/stg/stg/ipropertysetstorage.asp

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

    MS also have a sample ActiveX control (with source apparently) that may help:
    http://support.microsoft.com/support/kb/articles/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
     
    Chris Uppal, Feb 3, 2005
    #9
  10. Bhaskar Reddy

    prox99

    Joined:
    Oct 22, 2007
    Messages:
    1
    Chris, can you post the code to use ":\5SummaryInformation" for file summary information?

    Thanks

    Ming
     
    prox99, Oct 22, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Doug
    Replies:
    3
    Views:
    4,390
    Bruce Barker
    Nov 4, 2005
  2. Markus Bader
    Replies:
    2
    Views:
    5,869
    Markus Bader
    Nov 4, 2003
  3. sherazi
    Replies:
    1
    Views:
    765
    Roedy Green
    Sep 2, 2005
  4. Sreejith K
    Replies:
    24
    Views:
    1,044
    Sreejith K
    Mar 24, 2009
  5. Alex Dowad
    Replies:
    4
    Views:
    283
    Michel Demazure
    May 1, 2010
Loading...

Share This Page