I am accustomed to java.io.* and java.util.* but not to the tree:
com.starbase.util
Class FileUtils
java.lang.Object
|
+--com.starbase.util.FileUtils
So which class should I import to use the isBinary-method? Do I do “import java.lang.Object;” or “import java.lang.Object.com.starbase.util.FileUtils;”?
You would do
import com.starbase.util.FileUtils;orimport static com.starbase.util.FileUtils.*. The hierarchy is just showing that the classFileUtilsextendsObject(as do all classes).You do also have to have the .jar file/API to access this class.
EDIT: Added possible standalone implementation:
If you want to implement this yourself (I noticed your own ‘trivial’ answer), you could do something like this:
Please note, I have not tested this.
I should add that this is the trivial implementation. There are many kinds of text files that would be considered binary with this. If you were to allow text to be Unicode and/or UTF-8 (or other text encoding) then this quickly becomes very difficult. Then you need to develop some kinds of heuristics to differentiate between the kinds of files and this would not be 100% accurate. So, it really depends on what you are trying to do with this.