T
Thomas Weidenfeller
max said:I receive a file in an InputStream , and I'd like to know which kind of
file is it, compressed, or not.
How can I do it?
Only with difficulties. Java SE does not provide any file type detection
feature. You would have to re-create what some operating systems like
Unix do: They look for "magic numbers" in the file, and according to
what they find they guess a file type.
If you know the exact encoding of your compressed data, and if the
encoding starts with some typical magic number you can check for it by
e.g. using a PushbackInputStream to look ahead in the stream and check
for some numbers.
/Thomas