posted 17 years ago
You can also perform slightly other checks; use "name.regionMatches(true, name.length - 4, ".txt", 0, 4)" to check while ignoring the case.
There is one draw back: when saving, JFileChooser allows any typed in value. If that value does not include the correct extension, it is not added automatically but you have to do it yourself.