-4

I have file for example 5555.33 but in fact file is arj archive file

String ext = FilenameUtils.getExtension("C:\\5555.33"); 

the Extension returns 33 file. How to get actual file type arj from this file

shms
  • 79
  • 1
  • 1
  • 8
  • 3
    The extension isn't `arj` it's `33`. If the extension were `arj`, the file would be named `5555.arj`. – Kayaman Apr 29 '15 at 10:57
  • The extension is no longer `arj`. You can try getting the mime-type: http://stackoverflow.com/questions/51438/getting-a-files-mime-type-in-java – ceekay Apr 29 '15 at 11:00

2 Answers2

1

ARJ archive files start with 0x60, 0xEA bytes. Just read the first two bytes to determine whether file is ARJ archive or not.

AzKa
  • 26
  • 2
0

It seems like you want the content after '.' . For this you can try

String str = "abc.txt";
System.out.println(str.substring(str.lastIndexOf(".")+1));

You can use

Files.probeContentType(path)

to know what type of file it is refered to

ceekay
  • 471
  • 3
  • 14
Ashishkumar Singh
  • 3,580
  • 1
  • 23
  • 41
  • It's already stated, that he does NOT want the actual extension (the thingy that's now behind the "."), but the ?old? or maybe just the mime-type (which is already answered in another question) – ceekay Apr 29 '15 at 11:05