I'm using SuperCSV to parse CSV files in my GUI application. I find that SuperCSV just does not do any validation whether the file is a CSV file, or at least a text file. However, users hope the program could do such validation in case they select a wrong file (for example, an xls file) by mistake.
Could somebody advise how I can check a file is a CSV file or at least text file easily? Thanks in advance
I don't know that there's any surefire way to test this, but you could probably come up with some rules of thumb. If a file name doesn't end with *.csv" or at least ".txt", chances are it's not a CSV file. Same if it doesn't contain a certain number of actual commas between each newline character. (Note that in some locales CSVs use semicolons instead of commas.)
Ping & DNS - updated with new look and Ping home screen widget