How to get file extention from Content-type.

Discussion in 'Java' started by shilpa, Jun 30, 2005.

  1. shilpa

    shilpa Guest

    Hi there,

    I want to get file extention from file's content-type.
    I wanted to handle file with blank name in my mail client.
    For handling this I need to create temporary file. For that I need to
    decide file extention based on content-type.

    getFileNameMap(..) function of UrlConnection constructs FileNameMap but
    FileNameMap has method just to fetch content type from file extetion. I
    want exactly opposite of this i.e File extention from Content-Type.

    It would be great if any one can help me.

    Thanks,
    Shilpa
     
    shilpa, Jun 30, 2005
    #1
    1. Advertising

  2. shilpa wrote:
    > I want to get file extention from file's content-type.
    > I wanted to handle file with blank name in my mail client.
    > For handling this I need to create temporary file. For that I need to
    > decide file extention based on content-type.
    >
    > getFileNameMap(..) function of UrlConnection constructs FileNameMap but
    > FileNameMap has method just to fetch content type from file extetion. I
    > want exactly opposite of this i.e File extention from Content-Type.


    Sorry, but this doesn't make much sense. You talk about e-mail (which
    would be POP3, IMAP, SMTP or similar), then you talk about a file, but
    then you also talk about URLConnection (which would mean HTTP). So what
    is it from what you want to get some content type information? And what
    content type? I would guess we are talking MIME types here, aren't we?

    If it is e-mail, then JavaMail has the means to extract MIME parts from
    a mail and provide you with the MIME types of the parts. If it is a file
    you probably want the JavaBeans Activation Framework (JAF) alone. If it
    is HTTP and URLConnection is not enough, you might want to look into
    Apache/Jakarta/Commons.

    /Thomas

    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
     
    Thomas Weidenfeller, Jun 30, 2005
    #2
    1. Advertising

  3. shilpa

    shilpa Guest

    Thanks Thomas...

    Sorry for confusion caused..

    My problem is I want to handle mail attachments. and some mail client
    like Lotus notes sends attachments without file names.
    So my issue is I want to create temporary file for handling attachment
    without file name. So for that I want to have correct file extension.
    And for that I need to get File extesion from Content Type(Mime Type)

    So how to get file extesion from file name.

    Thanks
    Shilpa


    Thomas Weidenfeller wrote:
    > shilpa wrote:
    > > I want to get file extention from file's content-type.
    > > I wanted to handle file with blank name in my mail client.
    > > For handling this I need to create temporary file. For that I need to
    > > decide file extention based on content-type.
    > >
    > > getFileNameMap(..) function of UrlConnection constructs FileNameMap but
    > > FileNameMap has method just to fetch content type from file extetion. I
    > > want exactly opposite of this i.e File extention from Content-Type.

    >
    > Sorry, but this doesn't make much sense. You talk about e-mail (which
    > would be POP3, IMAP, SMTP or similar), then you talk about a file, but
    > then you also talk about URLConnection (which would mean HTTP). So what
    > is it from what you want to get some content type information? And what
    > content type? I would guess we are talking MIME types here, aren't we?
    >
    > If it is e-mail, then JavaMail has the means to extract MIME parts from
    > a mail and provide you with the MIME types of the parts. If it is a file
    > you probably want the JavaBeans Activation Framework (JAF) alone. If it
    > is HTTP and URLConnection is not enough, you might want to look into
    > Apache/Jakarta/Commons.
    >
    > /Thomas
    >
    > --
    > The comp.lang.java.gui FAQ:
    > ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    > http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
     
    shilpa, Jun 30, 2005
    #3
  4. shilpa

    shilpa Guest

    How to get File Extension from Content type?
    I just wanted to know is there something inbuilt available?

    I can write code and load content-types.properties file and get file
    extension from content type.

    If u have any info about same ..please let me know.

    Thanks

    shilpa wrote:
    > Thanks Thomas...
    >
    > Sorry for confusion caused..
    >
    > My problem is I want to handle mail attachments. and some mail client
    > like Lotus notes sends attachments without file names.
    > So my issue is I want to create temporary file for handling attachment
    > without file name. So for that I want to have correct file extension.
    > And for that I need to get File extesion from Content Type(Mime Type)
    >
    > So how to get file extesion from file name.
    >
    > Thanks
    > Shilpa
    >
    >
    > Thomas Weidenfeller wrote:
    > > shilpa wrote:
    > > > I want to get file extention from file's content-type.
    > > > I wanted to handle file with blank name in my mail client.
    > > > For handling this I need to create temporary file. For that I need to
    > > > decide file extention based on content-type.
    > > >
    > > > getFileNameMap(..) function of UrlConnection constructs FileNameMap but
    > > > FileNameMap has method just to fetch content type from file extetion. I
    > > > want exactly opposite of this i.e File extention from Content-Type.

    > >
    > > Sorry, but this doesn't make much sense. You talk about e-mail (which
    > > would be POP3, IMAP, SMTP or similar), then you talk about a file, but
    > > then you also talk about URLConnection (which would mean HTTP). So what
    > > is it from what you want to get some content type information? And what
    > > content type? I would guess we are talking MIME types here, aren't we?
    > >
    > > If it is e-mail, then JavaMail has the means to extract MIME parts from
    > > a mail and provide you with the MIME types of the parts. If it is a file
    > > you probably want the JavaBeans Activation Framework (JAF) alone. If it
    > > is HTTP and URLConnection is not enough, you might want to look into
    > > Apache/Jakarta/Commons.
    > >
    > > /Thomas
    > >
    > > --
    > > The comp.lang.java.gui FAQ:
    > > ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    > > http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
     
    shilpa, Jun 30, 2005
    #4
    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. Howard

    change file extention

    Howard, Jan 5, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,040
    Teemu Keiski
    Jan 5, 2006
  2. Stanimir Stamenkov
    Replies:
    2
    Views:
    755
    Stanimir Stamenkov
    Oct 25, 2005
  3. elho
    Replies:
    0
    Views:
    249
  4. Monu

    shelve file name extention

    Monu, Sep 8, 2008, in forum: Python
    Replies:
    4
    Views:
    400
    Fredrik Lundh
    Sep 11, 2008
  5. Ron

    Get file extention from path

    Ron, Jul 21, 2003, in forum: Perl Misc
    Replies:
    5
    Views:
    140
Loading...

Share This Page