Q:

Why I am getting mimetype text/plain for CSV file using JMimeMagic lib?

I am using JMimeMagic lib to validate CSV file upload.
For CSV and every other text file (txt, JSP etc) it gives me text/plain mime type. 
logger.debug("Checking magic content");
MagicMatch match;
match = Magic.getMagicMatch(getPromotionOptIn().getUpload(),false);
logger.debug("Actual file mimetype=" + match.getMimeType());

Should not I get text/csv for CSV file? (See all list of mime types). 
Or it's fine for it that I put my validation on text/plain thinking its a valid CSV file. 

A:

Since CSV files can have multiple different separators I suspect the csv file is just recognized as a text file (which is true).
If you see a text file how do you know for sure it is a CSV file? If there are commas, semi colons etc. in the text? What if those belong to an entry and the separator is something else (like |, #, @, etc.)?
You'll have difficulties with telling for sure without more information and JMimeMagic will have the same problems. Thus it will only return what it is sure about: the file is a text file. Thus you "only" get "text/plain".
I don't know that library but from the documentation/source it seems like you could give a hint that *.csv files have text/csv mime type using Magic.addHint("csv", someMatcher). Note that you might have to pass true for the second parameters as otherwise those hints might be ignored (seems so from looking at the sources).
That would still depend on the file extension to be correct, i.e. if someone uploaded a .csv file that contains something else you'll get the wrong mime type. 
However, it seems like JMimeMagic would not do much content checking anyways. At least I didn't find much in the sources I found at sourceforge/github. There's only a text file detector so you might have to add your own content detectors for other mime types and file formats.

