Package org.miaixz.bus.core.io.file
Enum Class FileMagicNumber
- All Implemented Interfaces:
Serializable,Comparable<FileMagicNumber>,Constable
文件类型魔数封装
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionaacac3aiffamrapngaravibmpbr https://github.com/madler/brotli/blob/master/br-format-v3.txt,brotli 没有固定的file magic number,所以此处只是参考bz2cabCHM 49 54 53 46class CA FE BA BEcrxdbxdcmdebdex https://source.android.com/devices/tech/dalvik/dex-format#dex-file-magicdeydocdocxdwgelfemlepubexeflacflvgifgziconjpegjxrlzlz4lzo3gpmp4m4vmdbmidimkvmov 此文件签名非常复杂,只判断常见的几种mpeg-mp3mp4mpgnesoggotfpdfpngpptpptxpspsdpstramrarrmvbrpmrtf7zsqliteswftartifftorrent 64 38 3A 61 6E 6E 6F 75 6E 63 65ttf未知类型wasmwavwebmwebpwmvwoff The existing registration "application/font-woff" is deprecated in favor of "font/woff".woff2wpdxcfxlsxlsxxzzipzst -
Method Summary
Modifier and TypeMethodDescription获取扩展名static FileMagicNumbergetMagicNumber(byte[] bytes) 根据给定的bytes,获取对应识别到的FileMagicNumber获取媒体类型abstract booleanmatch(byte[] bytes) 是否匹配bytesstatic FileMagicNumberReturns the enum constant of this class with the specified name.static FileMagicNumber[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
UNKNOWN
未知类型 -
JPEG
jpegprefix:FFD8FF -
JXR
jxrprefix:4949BC -
APNG
apngprefix 8位:89504E47 0D0A1A0A -
PNG
pngprefix: 89504E47 -
GIF
gifprefix: 474946 -
BMP
bmpprefix: 424D -
TIFF
tiffprefix: 49492A00 or 4D4D002A -
DWG
dwgprefix: 41433130 -
WEBP
webp[8:11]: 57454250 -
PSD
psdprefix: 38425053 -
ICO
iconprefix: 00000100 -
XCF
xcfprefix: 67696D70 20786366 2076 -
WAV
wavprefix: 52494646 [8:11]: 57415645 -
MIDI
midiprefix: 4D546864 -
MP3
mpeg-mp3prefix: 494433 or FFFB or FFF3 or FFF2 -
OGG
oggprefix: 4F676753 -
FLAC
flacprefix: 664C6143 -
M4A
mp4 -
AAC
aac -
AMR
amr -
AC3
ac3 -
AIFF
aiff -
WOFF
woff The existing registration "application/font-woff" is deprecated in favor of "font/woff". -
WOFF2
woff2 -
TTF
ttf -
OTF
otf -
EPUB
epub -
ZIP
zip -
TAR
tar -
RAR
rar -
GZ
gz -
BZ2
bz2 -
SevenZ
7z -
PDF
pdf -
EXE
exe -
SWF
swf -
RTF
rtf -
NES
nes -
CRX
crx -
CAB
cab -
PS
ps -
XZ
xz -
SQLITE
sqlite -
DEB
deb -
AR
ar -
LZOP
lzo -
LZ
lz -
ELF
elf -
LZ4
lz4 -
BR
br https://github.com/madler/brotli/blob/master/br-format-v3.txt,brotli 没有固定的file magic number,所以此处只是参考 -
DCM
dcm -
RPM
rpm -
ZSTD
zst -
MP4
mp4 -
AVI
avi -
WMV
wmv -
M4V
m4v -
FLV
flv -
MKV
mkv -
WEBM
webm -
MOV
mov 此文件签名非常复杂,只判断常见的几种 -
MPEG
mpg -
RMVB
rmvb -
M3GP
3gp -
DOC
doc -
XLS
xls -
PPT
ppt -
DOCX
docx -
PPTX
pptx -
XLSX
xlsx -
WASM
wasm -
DEX
dex https://source.android.com/devices/tech/dalvik/dex-format#dex-file-magic -
DEY
dey -
EML
eml -
MDB
mdb -
CHM
CHM 49 54 53 46 -
CLASS
class CA FE BA BE -
TORRENT
torrent 64 38 3A 61 6E 6E 6F 75 6E 63 65 -
WPD
wpd -
DBX
dbx -
PST
pst -
RAM
ram
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
getMagicNumber
根据给定的bytes,获取对应识别到的FileMagicNumber- Parameters:
bytes- bytes魔数- Returns:
FileMagicNumber
-
getMimeType
获取媒体类型- Returns:
- 媒体类型
-
getExtension
获取扩展名- Returns:
- 扩展名
-
match
public abstract boolean match(byte[] bytes) 是否匹配bytes- Parameters:
bytes- bytes- Returns:
- 是否匹配
-