Results 1 to 10 of 10
Thread: Reading file header
- 12-19-2007, 09:39 AM #1
Member
- Join Date
- Nov 2007
- Posts
- 70
- Rep Power
- 0
- 02-10-2009, 11:24 AM #2
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
even i want to know abt this..cn ny1 help me out
- 02-10-2009, 12:24 PM #3
Member
- Join Date
- Feb 2009
- Location
- Italy
- Posts
- 51
- Rep Power
- 0
File type
the class MimetypesFileTypeMap can be what you look for:
javax.activation.MimetypesFileTypeMap
it can tell you the MIME type of a file.... of course the problem is that some files like mp3 or pdf can have the same MIME type --> application/octet-stream
example:
another option....maybe better for you is FileSystemView:Java Code:File f = new File(filepath); System.out.println("Mime Type of " + f.getName() + " is " + new MimetypesFileTypeMap().getContentType(f));
javax.swing.filechooser.FileSystemView
it will tell you the system dependent type description of the file
example:
the problem of this method is that it will give different descriptions for file type, depending on the OS, on the language and on the software which registered for the interested file type:Java Code:File f = new File(filepath); System.out.println("System Type description of " + f.getName() + " is " + FileSystemView.getFileSystemView().getSystemTypeDescription(f));
example:
a pdf file can return "Adobe Acrobat 7.0 Document", "Adobe Acrobat Document", ......
EDIT:
another ....maybe even better option can be found at
schmidt.devlib.org/ffident/index.html
example:
this one doesn't check only the extension but i think it does a check also on the content and verifies it matchesJava Code:File f = new File(filepath); FormatDescription desc = FormatIdentification.identify(f); if (desc == null) { System.out.println("Unknown format."); } else System.out.println("Format=" + desc.getShortName() + ", MIME type=" + desc.getMimeType());
i hope this reply helpedLast edited by wolfcro; 02-10-2009 at 12:43 PM.
- 02-11-2009, 10:22 AM #4
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
How do i use FormatDescriptor??:confused:
- 02-11-2009, 11:04 AM #5
Member
- Join Date
- Feb 2009
- Location
- Italy
- Posts
- 51
- Rep Power
- 0
well the FormatDescription class can tell you with it's methods:
getShortName() -> the shor name of the type
example : PDF, JPG, MP3,...
getMimeType() -> a litte more detailed description
with this information you can make your program take decisions depending of the info.
stupid example:
File f = new File(filepath);
FormatDescription desc = FormatIdentification.identify(f);
Java Code:if (desc.getShortName().equals("PDF") System.out.println("You opened a PDF"); else if (desc.getShortName().equals("MP3") System.out.println("You opened an MP3");
- 02-14-2009, 06:48 AM #6
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
thanks wolfcro..cud u tel me any method to get the mp3 file's time...so tht i cn use wait fot tht much time
- 02-14-2009, 06:51 AM #7
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
cn thr be any wy to knw if the file is corrupted or not from the header wy or sum othr
- 02-18-2009, 09:25 AM #8
Member
- Join Date
- Feb 2009
- Location
- Italy
- Posts
- 51
- Rep Power
- 0
try searching google for :
java read mp3 tag
and you'll find some libraries for reading mp3 info
- 02-19-2009, 05:24 PM #9
Member
- Join Date
- Feb 2009
- Posts
- 5
- Rep Power
- 0
please help me out...how cn i use these libraries.....PLEASE HELP ME IN MY PROJECT:((
Last edited by pranjal; 02-21-2009 at 06:35 AM.
- 02-19-2009, 07:29 PM #10
Not good...
It appears to me that Wolfco is helping you with your project... remember this is voluntary help in this forum. I don't think it's a good idea to post demanding statements (caps & bolded) requesting/demanding help. It might have the oposite effect.
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
Similar Threads
-
Reading a properties file
By peiceonly in forum New To JavaReplies: 7Last Post: 05-06-2010, 05:17 PM -
Servlet sending the file (setting header)
By Java Tip in forum Java TipReplies: 0Last Post: 01-27-2008, 08:14 PM -
Reading a file
By mew in forum New To JavaReplies: 2Last Post: 12-30-2007, 12:23 PM -
Reading a file for use
By peachyco in forum New To JavaReplies: 2Last Post: 11-27-2007, 03:49 AM -
Reading from a file
By leebee in forum New To JavaReplies: 1Last Post: 07-23-2007, 12:02 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks