I need to create a filter that would filter files in a folder by extension. I prefer to create one filter that would combine several extensions and be case insensitive.
I am using FileNameExtensionFilter class from javax.swing
FileFilter filter = null;
filter = new FileNameExtensionFilter("Text file", "txt", "text");
which works fine on desktop but throws this on Android:
02-29 09:48:04.751: E/AndroidRuntime(25217): java.lang.NoClassDefFoundError: javax.swing.filechooser.FileNameExtensionFilter
Is there an alternative class that would work both on desktop and Android.
Thanks!
You could browse the code yourself and create your own version. There aren’t any swing dependencies apart from
FileNameExtensionFilteritself and its superclass.http://grepcode.com/file/repository.grepcode.com/java/root/jdk/openjdk/7-b147/javax/swing/filechooser/FileNameExtensionFilter.java