diff --git a/hutool-core/src/main/java/cn/hutool/core/array/PrimitiveArrayUtil.java b/hutool-core/src/main/java/cn/hutool/core/array/PrimitiveArrayUtil.java index c62ccf48b..d873cfba9 100644 --- a/hutool-core/src/main/java/cn/hutool/core/array/PrimitiveArrayUtil.java +++ b/hutool-core/src/main/java/cn/hutool/core/array/PrimitiveArrayUtil.java @@ -3155,7 +3155,7 @@ public class PrimitiveArrayUtil { * @param prefix 前缀 * @return 是否开头 */ - public static boolean startWith(final boolean[] array, final boolean[] prefix) { + public static boolean startWith(final boolean[] array, final boolean... prefix) { if (array == prefix) { return true; } @@ -3186,7 +3186,7 @@ public class PrimitiveArrayUtil { * @param prefix 前缀 * @return 是否开头 */ - public static boolean startWith(final byte[] array, final byte[] prefix) { + public static boolean startWith(final byte[] array, final byte... prefix) { if (array == prefix) { return true; } @@ -3212,7 +3212,7 @@ public class PrimitiveArrayUtil { * @param prefix 前缀 * @return 是否开头 */ - public static boolean startWith(final char[] array, final char[] prefix) { + public static boolean startWith(final char[] array, final char... prefix) { if (array == prefix) { return true; } @@ -3243,7 +3243,7 @@ public class PrimitiveArrayUtil { * @param prefix 前缀 * @return 是否开头 */ - public static boolean startWith(final double[] array, final double[] prefix) { + public static boolean startWith(final double[] array, final double... prefix) { if (array == prefix) { return true; } @@ -3274,7 +3274,7 @@ public class PrimitiveArrayUtil { * @param prefix 前缀 * @return 是否开头 */ - public static boolean startWith(final float[] array, final float[] prefix) { + public static boolean startWith(final float[] array, final float... prefix) { if (array == prefix) { return true; } @@ -3305,7 +3305,7 @@ public class PrimitiveArrayUtil { * @param prefix 前缀 * @return 是否开头 */ - public static boolean startWith(final int[] array, final int[] prefix) { + public static boolean startWith(final int[] array, final int... prefix) { if (array == prefix) { return true; } @@ -3336,7 +3336,7 @@ public class PrimitiveArrayUtil { * @param prefix 前缀 * @return 是否开头 */ - public static boolean startWith(final long[] array, final long[] prefix) { + public static boolean startWith(final long[] array, final long... prefix) { if (array == prefix) { return true; } @@ -3367,7 +3367,7 @@ public class PrimitiveArrayUtil { * @param prefix 前缀 * @return 是否开头 */ - public static boolean startWith(final short[] array, final short[] prefix) { + public static boolean startWith(final short[] array, final short... prefix) { if (array == prefix) { return true; } @@ -3402,7 +3402,7 @@ public class PrimitiveArrayUtil { * @param subArray 子数组 * @return 是否局部匹配 */ - public static boolean isSubEquals(final byte[] array, final int offset, final byte[] subArray) { + public static boolean isSubEquals(final byte[] array, final int offset, final byte... subArray) { if (array == subArray) { return true; } diff --git a/hutool-core/src/main/java/cn/hutool/core/io/file/FileMagicNumber.java b/hutool-core/src/main/java/cn/hutool/core/io/file/FileMagicNumber.java index ed2576915..4e389b6ab 100644 --- a/hutool-core/src/main/java/cn/hutool/core/io/file/FileMagicNumber.java +++ b/hutool-core/src/main/java/cn/hutool/core/io/file/FileMagicNumber.java @@ -38,44 +38,48 @@ public enum FileMagicNumber { // region ----- image /** * jpeg + *
+ * prefix:FFD8FF + **/ JPEG("image/jpeg", "jpg") { @Override public boolean match(final byte[] bytes) { return bytes.length > 2 - && Objects.equals(bytes[0], (byte) 0xff) - && Objects.equals(bytes[1], (byte) 0xd8) - && Objects.equals(bytes[2], (byte) 0xff); + && Objects.equals(bytes[0], (byte) 0xff) + && Objects.equals(bytes[1], (byte) 0xd8) + && Objects.equals(bytes[2], (byte) 0xff); } }, /** * jxr + *
+ * prefix:4949BC + **/ JXR("image/vnd.ms-photo", "jxr") { @Override public boolean match(final byte[] bytes) { //file magic number https://www.iana.org/assignments/media-types/image/jxr return bytes.length > 2 - && Objects.equals(bytes[0], (byte) 0x49) - && Objects.equals(bytes[1], (byte) 0x49) - && Objects.equals(bytes[2], (byte) 0xbc); + && Objects.equals(bytes[0], (byte) 0x49) + && Objects.equals(bytes[1], (byte) 0x49) + && Objects.equals(bytes[2], (byte) 0xbc); } }, /** * apng + *
+ * prefix 8位:89504E47 0D0A1A0A + **/ APNG("image/apng", "apng") { @Override public boolean match(final byte[] bytes) { - final boolean b = bytes.length > 8 - && Objects.equals(bytes[0], (byte) 0x89) - && Objects.equals(bytes[1], (byte) 0x50) - && Objects.equals(bytes[2], (byte) 0x4e) - && Objects.equals(bytes[3], (byte) 0x47) - && Objects.equals(bytes[4], (byte) 0x0d) - && Objects.equals(bytes[5], (byte) 0x0a) - && Objects.equals(bytes[6], (byte) 0x1a) - && Objects.equals(bytes[7], (byte) 0x0a); + final boolean b = ArrayUtil.startWith(bytes, + (byte) 0x89, (byte) 0x50, (byte) 0x4e, (byte) 0x47, + (byte) 0x0d, (byte) 0x0a, (byte) 0x1a, (byte) 0x0a + ); if (b) { int i = 8; @@ -101,130 +105,132 @@ public enum FileMagicNumber { }, /** * png + *
+ * prefix: 89504E47 + **/ PNG("image/png", "png") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x89) - && Objects.equals(bytes[1], (byte) 0x50) - && Objects.equals(bytes[2], (byte) 0x4e) - && Objects.equals(bytes[3], (byte) 0x47); + return ArrayUtil.startWith(bytes, + (byte) 0x89, (byte) 0x50, (byte) 0x4e, (byte) 0x47 + ); } }, /** * gif + *
+ * prefix: 474946 + **/ GIF("image/gif", "gif") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 2 - && Objects.equals(bytes[0], (byte) 0x47) - && Objects.equals(bytes[1], (byte) 0x49) - && Objects.equals(bytes[2], (byte) 0x46); + return ArrayUtil.startWith(bytes, + (byte) 0x47, (byte) 0x49, (byte) 0x46 + ); } }, /** * bmp + *
+ * prefix: 424D + **/ BMP("image/bmp", "bmp") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 1 - && Objects.equals(bytes[0], (byte) 0x42) - && Objects.equals(bytes[1], (byte) 0x4d); + return ArrayUtil.startWith(bytes, + (byte) 0x42, (byte) 0x4d + ); } }, /** * tiff + *
+ * prefix: 49492A00 or 4D4D002A + **/ TIFF("image/tiff", "tiff") { @Override public boolean match(final byte[] bytes) { - if (bytes.length < 4) { - return false; - } - final boolean flag1 = Objects.equals(bytes[0], (byte) 0x49) - && Objects.equals(bytes[1], (byte) 0x49) - && Objects.equals(bytes[2], (byte) 0x2a) - && Objects.equals(bytes[3], (byte) 0x00); - final boolean flag2 = (Objects.equals(bytes[0], (byte) 0x4d) - && Objects.equals(bytes[1], (byte) 0x4d) - && Objects.equals(bytes[2], (byte) 0x00) - && Objects.equals(bytes[3], (byte) 0x2a)); - return flag1 || flag2; - + return ArrayUtil.startWith(bytes, + (byte) 0x49, (byte) 0x49, (byte) 0x2a, (byte) 0x00 + ) || ArrayUtil.startWith(bytes, + (byte) 0x4d, (byte) 0x4d, (byte) 0x00, (byte) 0x2a + ); } }, /** * dwg + *
+ * prefix: 41433130 + **/ DWG("image/vnd.dwg", "dwg") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 10 - && Objects.equals(bytes[0], (byte) 0x41) - && Objects.equals(bytes[1], (byte) 0x43) - && Objects.equals(bytes[2], (byte) 0x31) - && Objects.equals(bytes[3], (byte) 0x30); + return ArrayUtil.startWith(bytes, + (byte) 0x41, (byte) 0x43, (byte) 0x31, (byte) 0x30 + ); } }, /** * webp + *
+ * [8:11]: 57454250 + **/ WEBP("image/webp", "webp") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 11 - && Objects.equals(bytes[8], (byte) 0x57) - && Objects.equals(bytes[9], (byte) 0x45) - && Objects.equals(bytes[10], (byte) 0x42) - && Objects.equals(bytes[11], (byte) 0x50); + return ArrayUtil.isSubEquals(bytes, 8, + (byte) 0x57, (byte) 0x45, (byte) 0x42, (byte) 0x50 + ); } }, /** * psd + *
+ * prefix: 38425053 + **/ PSD("image/vnd.adobe.photoshop", "psd") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x38) - && Objects.equals(bytes[1], (byte) 0x42) - && Objects.equals(bytes[2], (byte) 0x50) - && Objects.equals(bytes[3], (byte) 0x53); + return ArrayUtil.startWith(bytes, + (byte) 0x38, (byte) 0x42, (byte) 0x50, (byte) 0x53 + ); } }, /** * icon + *
+ * prefix: 00000100 + **/ ICO("image/x-icon", "ico") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x00) - && Objects.equals(bytes[1], (byte) 0x00) - && Objects.equals(bytes[2], (byte) 0x01) - && Objects.equals(bytes[3], (byte) 0x00); + return ArrayUtil.startWith(bytes, + (byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00 + ); } }, /** * xcf + *
+ * prefix: 67696D70 20786366 2076 + **/ XCF("image/x-xcf", "xcf") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 9 - && Objects.equals(bytes[0], (byte) 0x67) - && Objects.equals(bytes[1], (byte) 0x69) - && Objects.equals(bytes[2], (byte) 0x6d) - && Objects.equals(bytes[3], (byte) 0x70) - && Objects.equals(bytes[4], (byte) 0x20) - && Objects.equals(bytes[5], (byte) 0x78) - && Objects.equals(bytes[6], (byte) 0x63) - && Objects.equals(bytes[7], (byte) 0x66) - && Objects.equals(bytes[8], (byte) 0x20) - && Objects.equals(bytes[9], (byte) 0x76); + return ArrayUtil.startWith(bytes, + (byte) 0x67, (byte) 0x69, (byte) 0x6d, (byte) 0x70, + (byte) 0x20, (byte) 0x78, (byte) 0x63, (byte) 0x66, + (byte) 0x20, (byte) 0x76 + ); } }, // endregion @@ -232,61 +238,67 @@ public enum FileMagicNumber { // region ----- audio /** * wav + *
+ * prefix: 52494646 + * [8:11]: 57415645 + **/ WAV("audio/x-wav", "wav") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 11 - && Objects.equals(bytes[0], (byte) 0x52) - && Objects.equals(bytes[1], (byte) 0x49) - && Objects.equals(bytes[2], (byte) 0x46) - && Objects.equals(bytes[3], (byte) 0x46) - && Objects.equals(bytes[8], (byte) 0x57) - && Objects.equals(bytes[9], (byte) 0x41) - && Objects.equals(bytes[10], (byte) 0x56) - && Objects.equals(bytes[11], (byte) 0x45); + return ArrayUtil.startWith(bytes, + (byte) 0x52, (byte) 0x49, (byte) 0x46, (byte) 0x46 + ) && ArrayUtil.isSubEquals(bytes, 8, + (byte) 0x57, (byte) 0x41, (byte) 0x56, (byte) 0x45 + ); } }, /** * midi + *
+ * prefix: 4D546864 + **/ MIDI("audio/midi", "midi") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x4d) - && Objects.equals(bytes[1], (byte) 0x54) - && Objects.equals(bytes[2], (byte) 0x68) - && Objects.equals(bytes[3], (byte) 0x64); + return ArrayUtil.startWith(bytes, + (byte) 0x4d, (byte) 0x54, (byte) 0x68, (byte) 0x64 + ); } }, /** * mpeg-mp3 + *
+ * prefix: 494433 or FFFB or FFF3 or FFF2 + **/ MP3("audio/mpeg", "mp3") { @Override public boolean match(final byte[] bytes) { - if (bytes.length < 2) { - return false; - } - final boolean flag1 = Objects.equals(bytes[0], (byte) 0x49) && Objects.equals(bytes[1], (byte) 0x44) && Objects.equals(bytes[2], (byte) 0x33); - final boolean flag2 = Objects.equals(bytes[0], (byte) 0xFF) && Objects.equals(bytes[1], (byte) 0xFB); - final boolean flag3 = Objects.equals(bytes[0], (byte) 0xFF) && Objects.equals(bytes[1], (byte) 0xF3); - final boolean flag4 = Objects.equals(bytes[0], (byte) 0xFF) && Objects.equals(bytes[1], (byte) 0xF2); - return flag1 || flag2 || flag3 || flag4; + return ArrayUtil.startWith(bytes, + (byte) 0x49, (byte) 0x44, (byte) 0x33 + ) || ArrayUtil.startWith(bytes, + (byte) 0xFF, (byte) 0xFB + ) || ArrayUtil.startWith(bytes, + (byte) 0xFF, (byte) 0xF3 + ) || ArrayUtil.startWith(bytes, + (byte) 0xFF, (byte) 0xF2 + ); } }, /** * ogg + *
+ * prefix: 4F676753 + **/ OGG("audio/ogg", "ogg") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x4f) - && Objects.equals(bytes[1], (byte) 0x67) - && Objects.equals(bytes[2], (byte) 0x67) - && Objects.equals(bytes[3], (byte) 0x53); + return ArrayUtil.startWith(bytes, + (byte) 0x4F, (byte) 0x67, (byte) 0x67, (byte) 0x53 + ); } }, /** @@ -295,11 +307,9 @@ public enum FileMagicNumber { FLAC("audio/x-flac", "flac") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x66) - && Objects.equals(bytes[1], (byte) 0x4c) - && Objects.equals(bytes[2], (byte) 0x61) - && Objects.equals(bytes[3], (byte) 0x43); + return ArrayUtil.startWith(bytes, + (byte) 0x66, (byte) 0x4c, (byte) 0x61, (byte) 0x43 + ); } }, /** @@ -309,17 +319,17 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return (bytes.length > 10 - && Objects.equals(bytes[4], (byte) 0x66) - && Objects.equals(bytes[5], (byte) 0x74) - && Objects.equals(bytes[6], (byte) 0x79) - && Objects.equals(bytes[7], (byte) 0x70) - && Objects.equals(bytes[8], (byte) 0x4d) - && Objects.equals(bytes[9], (byte) 0x34) - && Objects.equals(bytes[10], (byte) 0x41)) - || (Objects.equals(bytes[0], (byte) 0x4d) - && Objects.equals(bytes[1], (byte) 0x34) - && Objects.equals(bytes[2], (byte) 0x41) - && Objects.equals(bytes[3], (byte) 0x20)); + && Objects.equals(bytes[4], (byte) 0x66) + && Objects.equals(bytes[5], (byte) 0x74) + && Objects.equals(bytes[6], (byte) 0x79) + && Objects.equals(bytes[7], (byte) 0x70) + && Objects.equals(bytes[8], (byte) 0x4d) + && Objects.equals(bytes[9], (byte) 0x34) + && Objects.equals(bytes[10], (byte) 0x41)) + || (Objects.equals(bytes[0], (byte) 0x4d) + && Objects.equals(bytes[1], (byte) 0x34) + && Objects.equals(bytes[2], (byte) 0x41) + && Objects.equals(bytes[3], (byte) 0x20)); } }, /** @@ -342,30 +352,14 @@ public enum FileMagicNumber { AMR("audio/amr", "amr") { @Override public boolean match(final byte[] bytes) { - //single-channel - if (bytes.length < 11) { - return false; - } - final boolean flag1 = Objects.equals(bytes[0], (byte) 0x23) - && Objects.equals(bytes[1], (byte) 0x21) - && Objects.equals(bytes[2], (byte) 0x41) - && Objects.equals(bytes[3], (byte) 0x4d) - && Objects.equals(bytes[4], (byte) 0x52) - && Objects.equals(bytes[5], (byte) 0x0A); - //multi-channel: - final boolean flag2 = Objects.equals(bytes[0], (byte) 0x23) - && Objects.equals(bytes[1], (byte) 0x21) - && Objects.equals(bytes[2], (byte) 0x41) - && Objects.equals(bytes[3], (byte) 0x4d) - && Objects.equals(bytes[4], (byte) 0x52) - && Objects.equals(bytes[5], (byte) 0x5F) - && Objects.equals(bytes[6], (byte) 0x4d) - && Objects.equals(bytes[7], (byte) 0x43) - && Objects.equals(bytes[8], (byte) 0x31) - && Objects.equals(bytes[9], (byte) 0x2e) - && Objects.equals(bytes[10], (byte) 0x30) - && Objects.equals(bytes[11], (byte) 0x0a); - return flag1 || flag2; + return ArrayUtil.startWith(bytes, + (byte) 0x23, (byte) 0x21, (byte) 0x41, (byte) 0x4d, + (byte) 0x52, (byte) 0x0A + ) || ArrayUtil.startWith(bytes, + (byte) 0x23, (byte) 0x21, (byte) 0x41, (byte) 0x4d, + (byte) 0x52, (byte) 0x5F, (byte) 0x4d, (byte) 0x43, + (byte) 0x31, (byte) 0x2e, (byte) 0x30, (byte) 0x0a + ); } }, /** @@ -374,9 +368,9 @@ public enum FileMagicNumber { AC3("audio/ac3", "ac3") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 2 - && Objects.equals(bytes[0], (byte) 0x0b) - && Objects.equals(bytes[1], (byte) 0x77); + return ArrayUtil.startWith(bytes, + (byte) 0x0b, (byte) 0x77 + ); } }, /** @@ -386,14 +380,15 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 11 - && Objects.equals(bytes[0], (byte) 0x46) - && Objects.equals(bytes[1], (byte) 0x4f) - && Objects.equals(bytes[2], (byte) 0x52) - && Objects.equals(bytes[3], (byte) 0x4d) - && Objects.equals(bytes[8], (byte) 0x41) - && Objects.equals(bytes[9], (byte) 0x49) - && Objects.equals(bytes[10], (byte) 0x46) - && Objects.equals(bytes[11], (byte) 0x46); + && Objects.equals(bytes[0], (byte) 0x46) + && Objects.equals(bytes[1], (byte) 0x4f) + && Objects.equals(bytes[2], (byte) 0x52) + && Objects.equals(bytes[3], (byte) 0x4d) + + && Objects.equals(bytes[8], (byte) 0x41) + && Objects.equals(bytes[9], (byte) 0x49) + && Objects.equals(bytes[10], (byte) 0x46) + && Objects.equals(bytes[11], (byte) 0x46); } }, // endregion @@ -406,25 +401,29 @@ public enum FileMagicNumber { WOFF("font/woff", "woff") { @Override public boolean match(final byte[] bytes) { - if(bytes.length < 8){ + if (bytes.length < 8) { return false; } - final boolean flag1 = Objects.equals(bytes[0], (byte) 0x77) - && Objects.equals(bytes[1], (byte) 0x4f) - && Objects.equals(bytes[2], (byte) 0x46) - && Objects.equals(bytes[3], (byte) 0x46); - final boolean flag2 = Objects.equals(bytes[4], (byte) 0x00) - && Objects.equals(bytes[5], (byte) 0x01) - && Objects.equals(bytes[6], (byte) 0x00) - && Objects.equals(bytes[7], (byte) 0x00); - final boolean flag3 = Objects.equals(bytes[4], (byte) 0x4f) - && Objects.equals(bytes[5], (byte) 0x54) - && Objects.equals(bytes[6], (byte) 0x54) - && Objects.equals(bytes[7], (byte) 0x4f); - final boolean flag4 = Objects.equals(bytes[4], (byte) 0x74) - && Objects.equals(bytes[5], (byte) 0x72) - && Objects.equals(bytes[6], (byte) 0x75) - && Objects.equals(bytes[7], (byte) 0x65); + final boolean flag1 = + Objects.equals(bytes[0], (byte) 0x77) + && Objects.equals(bytes[1], (byte) 0x4f) + && Objects.equals(bytes[2], (byte) 0x46) + && Objects.equals(bytes[3], (byte) 0x46); + final boolean flag2 = + Objects.equals(bytes[4], (byte) 0x00) + && Objects.equals(bytes[5], (byte) 0x01) + && Objects.equals(bytes[6], (byte) 0x00) + && Objects.equals(bytes[7], (byte) 0x00); + final boolean flag3 = + Objects.equals(bytes[4], (byte) 0x4f) + && Objects.equals(bytes[5], (byte) 0x54) + && Objects.equals(bytes[6], (byte) 0x54) + && Objects.equals(bytes[7], (byte) 0x4f); + final boolean flag4 = + Objects.equals(bytes[4], (byte) 0x74) + && Objects.equals(bytes[5], (byte) 0x72) + && Objects.equals(bytes[6], (byte) 0x75) + && Objects.equals(bytes[7], (byte) 0x65); return flag1 && (flag2 || flag3 || flag4); } }, @@ -434,25 +433,29 @@ public enum FileMagicNumber { WOFF2("font/woff2", "woff2") { @Override public boolean match(final byte[] bytes) { - if(bytes.length < 8){ + if (bytes.length < 8) { return false; } - final boolean flag1 = Objects.equals(bytes[0], (byte) 0x77) - && Objects.equals(bytes[1], (byte) 0x4f) - && Objects.equals(bytes[2], (byte) 0x46) - && Objects.equals(bytes[3], (byte) 0x32); - final boolean flag2 = Objects.equals(bytes[4], (byte) 0x00) - && Objects.equals(bytes[5], (byte) 0x01) - && Objects.equals(bytes[6], (byte) 0x00) - && Objects.equals(bytes[7], (byte) 0x00); - final boolean flag3 = Objects.equals(bytes[4], (byte) 0x4f) - && Objects.equals(bytes[5], (byte) 0x54) - && Objects.equals(bytes[6], (byte) 0x54) - && Objects.equals(bytes[7], (byte) 0x4f); - final boolean flag4 = Objects.equals(bytes[4], (byte) 0x74) - && Objects.equals(bytes[5], (byte) 0x72) - && Objects.equals(bytes[6], (byte) 0x75) - && Objects.equals(bytes[7], (byte) 0x65); + final boolean flag1 = + Objects.equals(bytes[0], (byte) 0x77) + && Objects.equals(bytes[1], (byte) 0x4f) + && Objects.equals(bytes[2], (byte) 0x46) + && Objects.equals(bytes[3], (byte) 0x32); + final boolean flag2 = + Objects.equals(bytes[4], (byte) 0x00) + && Objects.equals(bytes[5], (byte) 0x01) + && Objects.equals(bytes[6], (byte) 0x00) + && Objects.equals(bytes[7], (byte) 0x00); + final boolean flag3 = + Objects.equals(bytes[4], (byte) 0x4f) + && Objects.equals(bytes[5], (byte) 0x54) + && Objects.equals(bytes[6], (byte) 0x54) + && Objects.equals(bytes[7], (byte) 0x4f); + final boolean flag4 = + Objects.equals(bytes[4], (byte) 0x74) + && Objects.equals(bytes[5], (byte) 0x72) + && Objects.equals(bytes[6], (byte) 0x75) + && Objects.equals(bytes[7], (byte) 0x65); return flag1 && (flag2 || flag3 || flag4); } }, @@ -463,11 +466,11 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 4 - && Objects.equals(bytes[0], (byte) 0x00) - && Objects.equals(bytes[1], (byte) 0x01) - && Objects.equals(bytes[2], (byte) 0x00) - && Objects.equals(bytes[3], (byte) 0x00) - && Objects.equals(bytes[4], (byte) 0x00); + && Objects.equals(bytes[0], (byte) 0x00) + && Objects.equals(bytes[1], (byte) 0x01) + && Objects.equals(bytes[2], (byte) 0x00) + && Objects.equals(bytes[3], (byte) 0x00) + && Objects.equals(bytes[4], (byte) 0x00); } }, /** @@ -477,11 +480,11 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 4 - && Objects.equals(bytes[0], (byte) 0x4f) - && Objects.equals(bytes[1], (byte) 0x54) - && Objects.equals(bytes[2], (byte) 0x54) - && Objects.equals(bytes[3], (byte) 0x4f) - && Objects.equals(bytes[4], (byte) 0x00); + && Objects.equals(bytes[0], (byte) 0x4f) + && Objects.equals(bytes[1], (byte) 0x54) + && Objects.equals(bytes[2], (byte) 0x54) + && Objects.equals(bytes[3], (byte) 0x4f) + && Objects.equals(bytes[4], (byte) 0x00); } }, // endregion @@ -494,22 +497,22 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 58 - && Objects.equals(bytes[0], (byte) 0x50) && Objects.equals(bytes[1], (byte) 0x4b) - && Objects.equals(bytes[2], (byte) 0x03) && Objects.equals(bytes[3], (byte) 0x04) - && Objects.equals(bytes[30], (byte) 0x6d) && Objects.equals(bytes[31], (byte) 0x69) - && Objects.equals(bytes[32], (byte) 0x6d) && Objects.equals(bytes[33], (byte) 0x65) - && Objects.equals(bytes[34], (byte) 0x74) && Objects.equals(bytes[35], (byte) 0x79) - && Objects.equals(bytes[36], (byte) 0x70) && Objects.equals(bytes[37], (byte) 0x65) - && Objects.equals(bytes[38], (byte) 0x61) && Objects.equals(bytes[39], (byte) 0x70) - && Objects.equals(bytes[40], (byte) 0x70) && Objects.equals(bytes[41], (byte) 0x6c) - && Objects.equals(bytes[42], (byte) 0x69) && Objects.equals(bytes[43], (byte) 0x63) - && Objects.equals(bytes[44], (byte) 0x61) && Objects.equals(bytes[45], (byte) 0x74) - && Objects.equals(bytes[46], (byte) 0x69) && Objects.equals(bytes[47], (byte) 0x6f) - && Objects.equals(bytes[48], (byte) 0x6e) && Objects.equals(bytes[49], (byte) 0x2f) - && Objects.equals(bytes[50], (byte) 0x65) && Objects.equals(bytes[51], (byte) 0x70) - && Objects.equals(bytes[52], (byte) 0x75) && Objects.equals(bytes[53], (byte) 0x62) - && Objects.equals(bytes[54], (byte) 0x2b) && Objects.equals(bytes[55], (byte) 0x7a) - && Objects.equals(bytes[56], (byte) 0x69) && Objects.equals(bytes[57], (byte) 0x70); + && Objects.equals(bytes[0], (byte) 0x50) && Objects.equals(bytes[1], (byte) 0x4b) + && Objects.equals(bytes[2], (byte) 0x03) && Objects.equals(bytes[3], (byte) 0x04) + && Objects.equals(bytes[30], (byte) 0x6d) && Objects.equals(bytes[31], (byte) 0x69) + && Objects.equals(bytes[32], (byte) 0x6d) && Objects.equals(bytes[33], (byte) 0x65) + && Objects.equals(bytes[34], (byte) 0x74) && Objects.equals(bytes[35], (byte) 0x79) + && Objects.equals(bytes[36], (byte) 0x70) && Objects.equals(bytes[37], (byte) 0x65) + && Objects.equals(bytes[38], (byte) 0x61) && Objects.equals(bytes[39], (byte) 0x70) + && Objects.equals(bytes[40], (byte) 0x70) && Objects.equals(bytes[41], (byte) 0x6c) + && Objects.equals(bytes[42], (byte) 0x69) && Objects.equals(bytes[43], (byte) 0x63) + && Objects.equals(bytes[44], (byte) 0x61) && Objects.equals(bytes[45], (byte) 0x74) + && Objects.equals(bytes[46], (byte) 0x69) && Objects.equals(bytes[47], (byte) 0x6f) + && Objects.equals(bytes[48], (byte) 0x6e) && Objects.equals(bytes[49], (byte) 0x2f) + && Objects.equals(bytes[50], (byte) 0x65) && Objects.equals(bytes[51], (byte) 0x70) + && Objects.equals(bytes[52], (byte) 0x75) && Objects.equals(bytes[53], (byte) 0x62) + && Objects.equals(bytes[54], (byte) 0x2b) && Objects.equals(bytes[55], (byte) 0x7a) + && Objects.equals(bytes[56], (byte) 0x69) && Objects.equals(bytes[57], (byte) 0x70); } }, /** @@ -534,11 +537,11 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 261 - && Objects.equals(bytes[257], (byte) 0x75) - && Objects.equals(bytes[258], (byte) 0x73) - && Objects.equals(bytes[259], (byte) 0x74) - && Objects.equals(bytes[260], (byte) 0x61) - && Objects.equals(bytes[261], (byte) 0x72); + && Objects.equals(bytes[257], (byte) 0x75) + && Objects.equals(bytes[258], (byte) 0x73) + && Objects.equals(bytes[259], (byte) 0x74) + && Objects.equals(bytes[260], (byte) 0x61) + && Objects.equals(bytes[261], (byte) 0x72); } }, /** @@ -548,13 +551,13 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 6 - && Objects.equals(bytes[0], (byte) 0x52) - && Objects.equals(bytes[1], (byte) 0x61) - && Objects.equals(bytes[2], (byte) 0x72) - && Objects.equals(bytes[3], (byte) 0x21) - && Objects.equals(bytes[4], (byte) 0x1a) - && Objects.equals(bytes[5], (byte) 0x07) - && (Objects.equals(bytes[6], (byte) 0x00) || Objects.equals(bytes[6], (byte) 0x01)); + && Objects.equals(bytes[0], (byte) 0x52) + && Objects.equals(bytes[1], (byte) 0x61) + && Objects.equals(bytes[2], (byte) 0x72) + && Objects.equals(bytes[3], (byte) 0x21) + && Objects.equals(bytes[4], (byte) 0x1a) + && Objects.equals(bytes[5], (byte) 0x07) + && (Objects.equals(bytes[6], (byte) 0x00) || Objects.equals(bytes[6], (byte) 0x01)); } }, /** @@ -564,9 +567,9 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 2 - && Objects.equals(bytes[0], (byte) 0x1f) - && Objects.equals(bytes[1], (byte) 0x8b) - && Objects.equals(bytes[2], (byte) 0x08); + && Objects.equals(bytes[0], (byte) 0x1f) + && Objects.equals(bytes[1], (byte) 0x8b) + && Objects.equals(bytes[2], (byte) 0x08); } }, /** @@ -576,9 +579,9 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 2 - && Objects.equals(bytes[0], (byte) 0x42) - && Objects.equals(bytes[1], (byte) 0x5a) - && Objects.equals(bytes[2], (byte) 0x68); + && Objects.equals(bytes[0], (byte) 0x42) + && Objects.equals(bytes[1], (byte) 0x5a) + && Objects.equals(bytes[2], (byte) 0x68); } }, /** @@ -588,13 +591,13 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 6 - && Objects.equals(bytes[0], (byte) 0x37) - && Objects.equals(bytes[1], (byte) 0x7a) - && Objects.equals(bytes[2], (byte) 0xbc) - && Objects.equals(bytes[3], (byte) 0xaf) - && Objects.equals(bytes[4], (byte) 0x27) - && Objects.equals(bytes[5], (byte) 0x1c) - && Objects.equals(bytes[6], (byte) 0x00); + && Objects.equals(bytes[0], (byte) 0x37) + && Objects.equals(bytes[1], (byte) 0x7a) + && Objects.equals(bytes[2], (byte) 0xbc) + && Objects.equals(bytes[3], (byte) 0xaf) + && Objects.equals(bytes[4], (byte) 0x27) + && Objects.equals(bytes[5], (byte) 0x1c) + && Objects.equals(bytes[6], (byte) 0x00); } }, /** @@ -605,15 +608,15 @@ public enum FileMagicNumber { public boolean match(byte[] bytes) { //去除bom头并且跳过三个字节 if (bytes.length > 3 && Objects.equals(bytes[0], (byte) 0xEF) - && Objects.equals(bytes[1], (byte) 0xBB) && Objects.equals(bytes[2], (byte) 0xBF)) { + && Objects.equals(bytes[1], (byte) 0xBB) && Objects.equals(bytes[2], (byte) 0xBF)) { // UTF8 Bom bytes = Arrays.copyOfRange(bytes, 3, bytes.length); } return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x25) - && Objects.equals(bytes[1], (byte) 0x50) - && Objects.equals(bytes[2], (byte) 0x44) - && Objects.equals(bytes[3], (byte) 0x46); + && Objects.equals(bytes[0], (byte) 0x25) + && Objects.equals(bytes[1], (byte) 0x50) + && Objects.equals(bytes[2], (byte) 0x44) + && Objects.equals(bytes[3], (byte) 0x46); } }, /** @@ -623,8 +626,8 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 1 - && Objects.equals(bytes[0], (byte) 0x4d) - && Objects.equals(bytes[1], (byte) 0x5a); + && Objects.equals(bytes[0], (byte) 0x4d) + && Objects.equals(bytes[1], (byte) 0x5a); } }, /** @@ -634,9 +637,9 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 2 - && (Objects.equals(bytes[0], 0x43) || Objects.equals(bytes[0], (byte) 0x46)) - && Objects.equals(bytes[1], (byte) 0x57) - && Objects.equals(bytes[2], (byte) 0x53); + && (Objects.equals(bytes[0], 0x43) || Objects.equals(bytes[0], (byte) 0x46)) + && Objects.equals(bytes[1], (byte) 0x57) + && Objects.equals(bytes[2], (byte) 0x53); } }, /** @@ -646,11 +649,11 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 4 - && Objects.equals(bytes[0], (byte) 0x7b) - && Objects.equals(bytes[1], (byte) 0x5c) - && Objects.equals(bytes[2], (byte) 0x72) - && Objects.equals(bytes[3], (byte) 0x74) - && Objects.equals(bytes[4], (byte) 0x66); + && Objects.equals(bytes[0], (byte) 0x7b) + && Objects.equals(bytes[1], (byte) 0x5c) + && Objects.equals(bytes[2], (byte) 0x72) + && Objects.equals(bytes[3], (byte) 0x74) + && Objects.equals(bytes[4], (byte) 0x66); } }, /** @@ -660,10 +663,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x4e) - && Objects.equals(bytes[1], (byte) 0x45) - && Objects.equals(bytes[2], (byte) 0x53) - && Objects.equals(bytes[3], (byte) 0x1a); + && Objects.equals(bytes[0], (byte) 0x4e) + && Objects.equals(bytes[1], (byte) 0x45) + && Objects.equals(bytes[2], (byte) 0x53) + && Objects.equals(bytes[3], (byte) 0x1a); } }, /** @@ -673,10 +676,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x43) - && Objects.equals(bytes[1], (byte) 0x72) - && Objects.equals(bytes[2], (byte) 0x32) - && Objects.equals(bytes[3], (byte) 0x34); + && Objects.equals(bytes[0], (byte) 0x43) + && Objects.equals(bytes[1], (byte) 0x72) + && Objects.equals(bytes[2], (byte) 0x32) + && Objects.equals(bytes[3], (byte) 0x34); } }, /** @@ -689,9 +692,9 @@ public enum FileMagicNumber { return false; } final boolean flag1 = Objects.equals(bytes[0], (byte) 0x4d) && Objects.equals(bytes[1], (byte) 0x53) - && Objects.equals(bytes[2], (byte) 0x43) && Objects.equals(bytes[3], (byte) 0x46); + && Objects.equals(bytes[2], (byte) 0x43) && Objects.equals(bytes[3], (byte) 0x46); final boolean flag2 = Objects.equals(bytes[0], (byte) 0x49) && Objects.equals(bytes[1], (byte) 0x53) - && Objects.equals(bytes[2], (byte) 0x63) && Objects.equals(bytes[3], (byte) 0x28); + && Objects.equals(bytes[2], (byte) 0x63) && Objects.equals(bytes[3], (byte) 0x28); return flag1 || flag2; } }, @@ -702,8 +705,8 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 1 - && Objects.equals(bytes[0], (byte) 0x25) - && Objects.equals(bytes[1], (byte) 0x21); + && Objects.equals(bytes[0], (byte) 0x25) + && Objects.equals(bytes[1], (byte) 0x21); } }, /** @@ -713,12 +716,12 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 5 - && Objects.equals(bytes[0], (byte) 0xFD) - && Objects.equals(bytes[1], (byte) 0x37) - && Objects.equals(bytes[2], (byte) 0x7A) - && Objects.equals(bytes[3], (byte) 0x58) - && Objects.equals(bytes[4], (byte) 0x5A) - && Objects.equals(bytes[5], (byte) 0x00); + && Objects.equals(bytes[0], (byte) 0xFD) + && Objects.equals(bytes[1], (byte) 0x37) + && Objects.equals(bytes[2], (byte) 0x7A) + && Objects.equals(bytes[3], (byte) 0x58) + && Objects.equals(bytes[4], (byte) 0x5A) + && Objects.equals(bytes[5], (byte) 0x00); } }, /** @@ -728,14 +731,14 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 15 - && Objects.equals(bytes[0], (byte) 0x53) && Objects.equals(bytes[1], (byte) 0x51) - && Objects.equals(bytes[2], (byte) 0x4c) && Objects.equals(bytes[3], (byte) 0x69) - && Objects.equals(bytes[4], (byte) 0x74) && Objects.equals(bytes[5], (byte) 0x65) - && Objects.equals(bytes[6], (byte) 0x20) && Objects.equals(bytes[7], (byte) 0x66) - && Objects.equals(bytes[8], (byte) 0x6f) && Objects.equals(bytes[9], (byte) 0x72) - && Objects.equals(bytes[10], (byte) 0x6d) && Objects.equals(bytes[11], (byte) 0x61) - && Objects.equals(bytes[12], (byte) 0x74) && Objects.equals(bytes[13], (byte) 0x20) - && Objects.equals(bytes[14], (byte) 0x33) && Objects.equals(bytes[15], (byte) 0x00); + && Objects.equals(bytes[0], (byte) 0x53) && Objects.equals(bytes[1], (byte) 0x51) + && Objects.equals(bytes[2], (byte) 0x4c) && Objects.equals(bytes[3], (byte) 0x69) + && Objects.equals(bytes[4], (byte) 0x74) && Objects.equals(bytes[5], (byte) 0x65) + && Objects.equals(bytes[6], (byte) 0x20) && Objects.equals(bytes[7], (byte) 0x66) + && Objects.equals(bytes[8], (byte) 0x6f) && Objects.equals(bytes[9], (byte) 0x72) + && Objects.equals(bytes[10], (byte) 0x6d) && Objects.equals(bytes[11], (byte) 0x61) + && Objects.equals(bytes[12], (byte) 0x74) && Objects.equals(bytes[13], (byte) 0x20) + && Objects.equals(bytes[14], (byte) 0x33) && Objects.equals(bytes[15], (byte) 0x00); } }, /** @@ -745,17 +748,17 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 20 - && Objects.equals(bytes[0], (byte) 0x21) && Objects.equals(bytes[1], (byte) 0x3c) - && Objects.equals(bytes[2], (byte) 0x61) && Objects.equals(bytes[3], (byte) 0x72) - && Objects.equals(bytes[4], (byte) 0x63) && Objects.equals(bytes[5], (byte) 0x68) - && Objects.equals(bytes[6], (byte) 0x3e) && Objects.equals(bytes[7], (byte) 0x0a) - && Objects.equals(bytes[8], (byte) 0x64) && Objects.equals(bytes[9], (byte) 0x65) - && Objects.equals(bytes[10], (byte) 0x62) && Objects.equals(bytes[11], (byte) 0x69) - && Objects.equals(bytes[12], (byte) 0x61) && Objects.equals(bytes[13], (byte) 0x6e) - && Objects.equals(bytes[14], (byte) 0x2d) && Objects.equals(bytes[15], (byte) 0x62) - && Objects.equals(bytes[16], (byte) 0x69) && Objects.equals(bytes[17], (byte) 0x6e) - && Objects.equals(bytes[18], (byte) 0x61) && Objects.equals(bytes[19], (byte) 0x72) - && Objects.equals(bytes[20], (byte) 0x79); + && Objects.equals(bytes[0], (byte) 0x21) && Objects.equals(bytes[1], (byte) 0x3c) + && Objects.equals(bytes[2], (byte) 0x61) && Objects.equals(bytes[3], (byte) 0x72) + && Objects.equals(bytes[4], (byte) 0x63) && Objects.equals(bytes[5], (byte) 0x68) + && Objects.equals(bytes[6], (byte) 0x3e) && Objects.equals(bytes[7], (byte) 0x0a) + && Objects.equals(bytes[8], (byte) 0x64) && Objects.equals(bytes[9], (byte) 0x65) + && Objects.equals(bytes[10], (byte) 0x62) && Objects.equals(bytes[11], (byte) 0x69) + && Objects.equals(bytes[12], (byte) 0x61) && Objects.equals(bytes[13], (byte) 0x6e) + && Objects.equals(bytes[14], (byte) 0x2d) && Objects.equals(bytes[15], (byte) 0x62) + && Objects.equals(bytes[16], (byte) 0x69) && Objects.equals(bytes[17], (byte) 0x6e) + && Objects.equals(bytes[18], (byte) 0x61) && Objects.equals(bytes[19], (byte) 0x72) + && Objects.equals(bytes[20], (byte) 0x79); } }, /** @@ -765,13 +768,13 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 6 - && Objects.equals(bytes[0], (byte) 0x21) - && Objects.equals(bytes[1], (byte) 0x3c) - && Objects.equals(bytes[2], (byte) 0x61) - && Objects.equals(bytes[3], (byte) 0x72) - && Objects.equals(bytes[4], (byte) 0x63) - && Objects.equals(bytes[5], (byte) 0x68) - && Objects.equals(bytes[6], (byte) 0x3e); + && Objects.equals(bytes[0], (byte) 0x21) + && Objects.equals(bytes[1], (byte) 0x3c) + && Objects.equals(bytes[2], (byte) 0x61) + && Objects.equals(bytes[3], (byte) 0x72) + && Objects.equals(bytes[4], (byte) 0x63) + && Objects.equals(bytes[5], (byte) 0x68) + && Objects.equals(bytes[6], (byte) 0x3e); } }, /** @@ -781,14 +784,14 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 7 - && Objects.equals(bytes[0], (byte) 0x89) - && Objects.equals(bytes[1], (byte) 0x4c) - && Objects.equals(bytes[2], (byte) 0x5a) - && Objects.equals(bytes[3], (byte) 0x4f) - && Objects.equals(bytes[4], (byte) 0x00) - && Objects.equals(bytes[5], (byte) 0x0d) - && Objects.equals(bytes[6], (byte) 0x0a) - && Objects.equals(bytes[7], (byte) 0x1a); + && Objects.equals(bytes[0], (byte) 0x89) + && Objects.equals(bytes[1], (byte) 0x4c) + && Objects.equals(bytes[2], (byte) 0x5a) + && Objects.equals(bytes[3], (byte) 0x4f) + && Objects.equals(bytes[4], (byte) 0x00) + && Objects.equals(bytes[5], (byte) 0x0d) + && Objects.equals(bytes[6], (byte) 0x0a) + && Objects.equals(bytes[7], (byte) 0x1a); } }, /** @@ -798,10 +801,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x4c) - && Objects.equals(bytes[1], (byte) 0x5a) - && Objects.equals(bytes[2], (byte) 0x49) - && Objects.equals(bytes[3], (byte) 0x50); + && Objects.equals(bytes[0], (byte) 0x4c) + && Objects.equals(bytes[1], (byte) 0x5a) + && Objects.equals(bytes[2], (byte) 0x49) + && Objects.equals(bytes[3], (byte) 0x50); } }, /** @@ -811,10 +814,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 52 - && Objects.equals(bytes[0], (byte) 0x7f) - && Objects.equals(bytes[1], (byte) 0x45) - && Objects.equals(bytes[2], (byte) 0x4c) - && Objects.equals(bytes[3], (byte) 0x46); + && Objects.equals(bytes[0], (byte) 0x7f) + && Objects.equals(bytes[1], (byte) 0x45) + && Objects.equals(bytes[2], (byte) 0x4c) + && Objects.equals(bytes[3], (byte) 0x46); } }, /** @@ -824,10 +827,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 4 - && Objects.equals(bytes[0], (byte) 0x04) - && Objects.equals(bytes[1], (byte) 0x22) - && Objects.equals(bytes[2], (byte) 0x4d) - && Objects.equals(bytes[3], (byte) 0x18); + && Objects.equals(bytes[0], (byte) 0x04) + && Objects.equals(bytes[1], (byte) 0x22) + && Objects.equals(bytes[2], (byte) 0x4d) + && Objects.equals(bytes[3], (byte) 0x18); } }, /** @@ -838,10 +841,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0xce) - && Objects.equals(bytes[1], (byte) 0xb2) - && Objects.equals(bytes[2], (byte) 0xcf) - && Objects.equals(bytes[3], (byte) 0x81); + && Objects.equals(bytes[0], (byte) 0xce) + && Objects.equals(bytes[1], (byte) 0xb2) + && Objects.equals(bytes[2], (byte) 0xcf) + && Objects.equals(bytes[3], (byte) 0x81); } }, /** @@ -851,10 +854,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 128 - && Objects.equals(bytes[128], (byte) 0x44) - && Objects.equals(bytes[129], (byte) 0x49) - && Objects.equals(bytes[130], (byte) 0x43) - && Objects.equals(bytes[131], (byte) 0x4d); + && Objects.equals(bytes[128], (byte) 0x44) + && Objects.equals(bytes[129], (byte) 0x49) + && Objects.equals(bytes[130], (byte) 0x43) + && Objects.equals(bytes[131], (byte) 0x4d); } }, /** @@ -864,10 +867,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 4 - && Objects.equals(bytes[0], (byte) 0xed) - && Objects.equals(bytes[1], (byte) 0xab) - && Objects.equals(bytes[2], (byte) 0xee) - && Objects.equals(bytes[3], (byte) 0xdb); + && Objects.equals(bytes[0], (byte) 0xed) + && Objects.equals(bytes[1], (byte) 0xab) + && Objects.equals(bytes[2], (byte) 0xee) + && Objects.equals(bytes[3], (byte) 0xdb); } }, /** @@ -882,9 +885,9 @@ public enum FileMagicNumber { } final byte[] buf1 = new byte[]{(byte) 0x22, (byte) 0x23, (byte) 0x24, (byte) 0x25, (byte) 0x26, (byte) 0x27, (byte) 0x28}; final boolean flag1 = ArrayUtil.contains(buf1, bytes[0]) - && Objects.equals(bytes[1], (byte) 0xb5) - && Objects.equals(bytes[2], (byte) 0x2f) - && Objects.equals(bytes[3], (byte) 0xfd); + && Objects.equals(bytes[1], (byte) 0xb5) + && Objects.equals(bytes[2], (byte) 0x2f) + && Objects.equals(bytes[3], (byte) 0xfd); if (flag1) { return true; } @@ -907,21 +910,21 @@ public enum FileMagicNumber { return false; } final boolean flag1 = Objects.equals(bytes[4], (byte) 0x66) - && Objects.equals(bytes[5], (byte) 0x74) - && Objects.equals(bytes[6], (byte) 0x79) - && Objects.equals(bytes[7], (byte) 0x70) - && Objects.equals(bytes[8], (byte) 0x4d) - && Objects.equals(bytes[9], (byte) 0x53) - && Objects.equals(bytes[10], (byte) 0x4e) - && Objects.equals(bytes[11], (byte) 0x56); + && Objects.equals(bytes[5], (byte) 0x74) + && Objects.equals(bytes[6], (byte) 0x79) + && Objects.equals(bytes[7], (byte) 0x70) + && Objects.equals(bytes[8], (byte) 0x4d) + && Objects.equals(bytes[9], (byte) 0x53) + && Objects.equals(bytes[10], (byte) 0x4e) + && Objects.equals(bytes[11], (byte) 0x56); final boolean flag2 = Objects.equals(bytes[4], (byte) 0x66) - && Objects.equals(bytes[5], (byte) 0x74) - && Objects.equals(bytes[6], (byte) 0x79) - && Objects.equals(bytes[7], (byte) 0x70) - && Objects.equals(bytes[8], (byte) 0x69) - && Objects.equals(bytes[9], (byte) 0x73) - && Objects.equals(bytes[10], (byte) 0x6f) - && Objects.equals(bytes[11], (byte) 0x6d); + && Objects.equals(bytes[5], (byte) 0x74) + && Objects.equals(bytes[6], (byte) 0x79) + && Objects.equals(bytes[7], (byte) 0x70) + && Objects.equals(bytes[8], (byte) 0x69) + && Objects.equals(bytes[9], (byte) 0x73) + && Objects.equals(bytes[10], (byte) 0x6f) + && Objects.equals(bytes[11], (byte) 0x6d); return flag1 || flag2; } }, @@ -932,14 +935,14 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 11 - && Objects.equals(bytes[0], (byte) 0x52) - && Objects.equals(bytes[1], (byte) 0x49) - && Objects.equals(bytes[2], (byte) 0x46) - && Objects.equals(bytes[3], (byte) 0x46) - && Objects.equals(bytes[8], (byte) 0x41) - && Objects.equals(bytes[9], (byte) 0x56) - && Objects.equals(bytes[10], (byte) 0x49) - && Objects.equals(bytes[11], (byte) 0x20); + && Objects.equals(bytes[0], (byte) 0x52) + && Objects.equals(bytes[1], (byte) 0x49) + && Objects.equals(bytes[2], (byte) 0x46) + && Objects.equals(bytes[3], (byte) 0x46) + && Objects.equals(bytes[8], (byte) 0x41) + && Objects.equals(bytes[9], (byte) 0x56) + && Objects.equals(bytes[10], (byte) 0x49) + && Objects.equals(bytes[11], (byte) 0x20); } }, /** @@ -949,16 +952,16 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 9 - && Objects.equals(bytes[0], (byte) 0x30) - && Objects.equals(bytes[1], (byte) 0x26) - && Objects.equals(bytes[2], (byte) 0xb2) - && Objects.equals(bytes[3], (byte) 0x75) - && Objects.equals(bytes[4], (byte) 0x8e) - && Objects.equals(bytes[5], (byte) 0x66) - && Objects.equals(bytes[6], (byte) 0xcf) - && Objects.equals(bytes[7], (byte) 0x11) - && Objects.equals(bytes[8], (byte) 0xa6) - && Objects.equals(bytes[9], (byte) 0xd9); + && Objects.equals(bytes[0], (byte) 0x30) + && Objects.equals(bytes[1], (byte) 0x26) + && Objects.equals(bytes[2], (byte) 0xb2) + && Objects.equals(bytes[3], (byte) 0x75) + && Objects.equals(bytes[4], (byte) 0x8e) + && Objects.equals(bytes[5], (byte) 0x66) + && Objects.equals(bytes[6], (byte) 0xcf) + && Objects.equals(bytes[7], (byte) 0x11) + && Objects.equals(bytes[8], (byte) 0xa6) + && Objects.equals(bytes[9], (byte) 0xd9); } }, /** @@ -971,21 +974,21 @@ public enum FileMagicNumber { return false; } final boolean flag1 = Objects.equals(bytes[4], (byte) 0x66) - && Objects.equals(bytes[5], (byte) 0x74) - && Objects.equals(bytes[6], (byte) 0x79) - && Objects.equals(bytes[7], (byte) 0x70) - && Objects.equals(bytes[8], (byte) 0x4d) - && Objects.equals(bytes[9], (byte) 0x34) - && Objects.equals(bytes[10], (byte) 0x56) - && Objects.equals(bytes[11], (byte) 0x20); + && Objects.equals(bytes[5], (byte) 0x74) + && Objects.equals(bytes[6], (byte) 0x79) + && Objects.equals(bytes[7], (byte) 0x70) + && Objects.equals(bytes[8], (byte) 0x4d) + && Objects.equals(bytes[9], (byte) 0x34) + && Objects.equals(bytes[10], (byte) 0x56) + && Objects.equals(bytes[11], (byte) 0x20); final boolean flag2 = Objects.equals(bytes[4], (byte) 0x66) - && Objects.equals(bytes[5], (byte) 0x74) - && Objects.equals(bytes[6], (byte) 0x79) - && Objects.equals(bytes[7], (byte) 0x70) - && Objects.equals(bytes[8], (byte) 0x6d) - && Objects.equals(bytes[9], (byte) 0x70) - && Objects.equals(bytes[10], (byte) 0x34) - && Objects.equals(bytes[11], (byte) 0x32); + && Objects.equals(bytes[5], (byte) 0x74) + && Objects.equals(bytes[6], (byte) 0x79) + && Objects.equals(bytes[7], (byte) 0x70) + && Objects.equals(bytes[8], (byte) 0x6d) + && Objects.equals(bytes[9], (byte) 0x70) + && Objects.equals(bytes[10], (byte) 0x34) + && Objects.equals(bytes[11], (byte) 0x32); return flag1 || flag2; } }, @@ -996,10 +999,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x46) - && Objects.equals(bytes[1], (byte) 0x4c) - && Objects.equals(bytes[2], (byte) 0x56) - && Objects.equals(bytes[3], (byte) 0x01); + && Objects.equals(bytes[0], (byte) 0x46) + && Objects.equals(bytes[1], (byte) 0x4c) + && Objects.equals(bytes[2], (byte) 0x56) + && Objects.equals(bytes[3], (byte) 0x01); } }, /** @@ -1010,10 +1013,10 @@ public enum FileMagicNumber { public boolean match(final byte[] bytes) { //0x42 0x82 0x88 0x6d 0x61 0x74 0x72 0x6f 0x73 0x6b 0x61 final boolean flag1 = bytes.length > 11 - && Objects.equals(bytes[0], (byte) 0x1a) - && Objects.equals(bytes[1], (byte) 0x45) - && Objects.equals(bytes[2], (byte) 0xdf) - && Objects.equals(bytes[3], (byte) 0xa3); + && Objects.equals(bytes[0], (byte) 0x1a) + && Objects.equals(bytes[1], (byte) 0x45) + && Objects.equals(bytes[2], (byte) 0xdf) + && Objects.equals(bytes[3], (byte) 0xa3); if (flag1) { //此处需要判断是否是'\x42\x82\x88matroska',算法类似kmp判断 @@ -1031,10 +1034,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { final boolean flag1 = bytes.length > 8 - && Objects.equals(bytes[0], (byte) 0x1a) - && Objects.equals(bytes[1], (byte) 0x45) - && Objects.equals(bytes[2], (byte) 0xdf) - && Objects.equals(bytes[3], (byte) 0xa3); + && Objects.equals(bytes[0], (byte) 0x1a) + && Objects.equals(bytes[1], (byte) 0x45) + && Objects.equals(bytes[2], (byte) 0xdf) + && Objects.equals(bytes[3], (byte) 0xa3); if (flag1) { //此处需要判断是否是'\x42\x82\x88webm',算法类似kmp判断 final byte[] bytes1 = {(byte) 0x42, (byte) 0x82, (byte) 0x88, (byte) 0x77, (byte) 0x65, (byte) 0x62, (byte) 0x6d}; @@ -1055,37 +1058,37 @@ public enum FileMagicNumber { return false; } final boolean flag1 = Objects.equals(bytes[4], (byte) 0x66) - && Objects.equals(bytes[5], (byte) 0x74) - && Objects.equals(bytes[6], (byte) 0x79) - && Objects.equals(bytes[7], (byte) 0x70) - && Objects.equals(bytes[8], (byte) 0x71) - && Objects.equals(bytes[9], (byte) 0x74) - && Objects.equals(bytes[10], (byte) 0x20) - && Objects.equals(bytes[11], (byte) 0x20); + && Objects.equals(bytes[5], (byte) 0x74) + && Objects.equals(bytes[6], (byte) 0x79) + && Objects.equals(bytes[7], (byte) 0x70) + && Objects.equals(bytes[8], (byte) 0x71) + && Objects.equals(bytes[9], (byte) 0x74) + && Objects.equals(bytes[10], (byte) 0x20) + && Objects.equals(bytes[11], (byte) 0x20); final boolean flag2 = Objects.equals(bytes[4], (byte) 0x6D) - && Objects.equals(bytes[5], (byte) 0x6F) - && Objects.equals(bytes[6], (byte) 0x6F) - && Objects.equals(bytes[7], (byte) 0x76); + && Objects.equals(bytes[5], (byte) 0x6F) + && Objects.equals(bytes[6], (byte) 0x6F) + && Objects.equals(bytes[7], (byte) 0x76); final boolean flag3 = Objects.equals(bytes[4], (byte) 0x66) - && Objects.equals(bytes[5], (byte) 0x72) - && Objects.equals(bytes[6], (byte) 0x65) - && Objects.equals(bytes[7], (byte) 0x65); + && Objects.equals(bytes[5], (byte) 0x72) + && Objects.equals(bytes[6], (byte) 0x65) + && Objects.equals(bytes[7], (byte) 0x65); final boolean flag4 = Objects.equals(bytes[4], (byte) 0x6D) - && Objects.equals(bytes[5], (byte) 0x64) - && Objects.equals(bytes[6], (byte) 0x61) - && Objects.equals(bytes[7], (byte) 0x74); + && Objects.equals(bytes[5], (byte) 0x64) + && Objects.equals(bytes[6], (byte) 0x61) + && Objects.equals(bytes[7], (byte) 0x74); final boolean flag5 = Objects.equals(bytes[4], (byte) 0x77) - && Objects.equals(bytes[5], (byte) 0x69) - && Objects.equals(bytes[6], (byte) 0x64) - && Objects.equals(bytes[7], (byte) 0x65); + && Objects.equals(bytes[5], (byte) 0x69) + && Objects.equals(bytes[6], (byte) 0x64) + && Objects.equals(bytes[7], (byte) 0x65); final boolean flag6 = Objects.equals(bytes[4], (byte) 0x70) - && Objects.equals(bytes[5], (byte) 0x6E) - && Objects.equals(bytes[6], (byte) 0x6F) - && Objects.equals(bytes[7], (byte) 0x74); + && Objects.equals(bytes[5], (byte) 0x6E) + && Objects.equals(bytes[6], (byte) 0x6F) + && Objects.equals(bytes[7], (byte) 0x74); final boolean flag7 = Objects.equals(bytes[4], (byte) 0x73) - && Objects.equals(bytes[5], (byte) 0x6B) - && Objects.equals(bytes[6], (byte) 0x69) - && Objects.equals(bytes[7], (byte) 0x70); + && Objects.equals(bytes[5], (byte) 0x6B) + && Objects.equals(bytes[6], (byte) 0x69) + && Objects.equals(bytes[7], (byte) 0x70); return flag1 || flag2 || flag3 || flag4 || flag5 || flag6 || flag7; } }, @@ -1096,10 +1099,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 3 - && Objects.equals(bytes[0], (byte) 0x00) - && Objects.equals(bytes[1], (byte) 0x00) - && Objects.equals(bytes[2], (byte) 0x01) - && (bytes[3] >= (byte) 0xb0 && bytes[3] <= (byte) 0xbf); + && Objects.equals(bytes[0], (byte) 0x00) + && Objects.equals(bytes[1], (byte) 0x00) + && Objects.equals(bytes[2], (byte) 0x01) + && (bytes[3] >= (byte) 0xb0 && bytes[3] <= (byte) 0xbf); } }, /** @@ -1109,10 +1112,10 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 4 - && Objects.equals(bytes[0], (byte) 0x2E) - && Objects.equals(bytes[1], (byte) 0x52) - && Objects.equals(bytes[2], (byte) 0x4D) - && Objects.equals(bytes[3], (byte) 0x46); + && Objects.equals(bytes[0], (byte) 0x2E) + && Objects.equals(bytes[1], (byte) 0x52) + && Objects.equals(bytes[2], (byte) 0x4D) + && Objects.equals(bytes[3], (byte) 0x46); } }, /** @@ -1122,13 +1125,13 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 10 - && Objects.equals(bytes[4], (byte) 0x66) - && Objects.equals(bytes[5], (byte) 0x74) - && Objects.equals(bytes[6], (byte) 0x79) - && Objects.equals(bytes[7], (byte) 0x70) - && Objects.equals(bytes[8], (byte) 0x33) - && Objects.equals(bytes[9], (byte) 0x67) - && Objects.equals(bytes[10], (byte) 0x70); + && Objects.equals(bytes[4], (byte) 0x66) + && Objects.equals(bytes[5], (byte) 0x74) + && Objects.equals(bytes[6], (byte) 0x79) + && Objects.equals(bytes[7], (byte) 0x70) + && Objects.equals(bytes[8], (byte) 0x33) + && Objects.equals(bytes[9], (byte) 0x67) + && Objects.equals(bytes[10], (byte) 0x70); } }, // endregion @@ -1144,13 +1147,13 @@ public enum FileMagicNumber { if (bytes.length > 515 && ArrayUtil.isSubEquals(bytes, 0, byte1)) { final byte[] byte2 = new byte[]{(byte) 0xec, (byte) 0xa5, (byte) 0xc1, (byte) 0x00}; // check 512:516 - if(ArrayUtil.isSubEquals(bytes, 512, byte2)){ + if (ArrayUtil.isSubEquals(bytes, 512, byte2)) { return true; } final byte[] byte3 = new byte[]{(byte) 0x00, (byte) 0x0a, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x4d, (byte) 0x53, (byte) 0x57, (byte) 0x6f, (byte) 0x72, (byte) 0x64 - , (byte) 0x44, (byte) 0x6f, (byte) 0x63, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x57, (byte) 0x6f, (byte) 0x72, (byte) 0x64, - (byte) 0x2e, (byte) 0x44, (byte) 0x6f, (byte) 0x63, (byte) 0x75, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x2e, (byte) 0x38, (byte) 0x00, - (byte) 0xf4, (byte) 0x39, (byte) 0xb2, (byte) 0x71}; + , (byte) 0x44, (byte) 0x6f, (byte) 0x63, (byte) 0x00, (byte) 0x10, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x57, (byte) 0x6f, (byte) 0x72, (byte) 0x64, + (byte) 0x2e, (byte) 0x44, (byte) 0x6f, (byte) 0x63, (byte) 0x75, (byte) 0x6d, (byte) 0x65, (byte) 0x6e, (byte) 0x74, (byte) 0x2e, (byte) 0x38, (byte) 0x00, + (byte) 0xf4, (byte) 0x39, (byte) 0xb2, (byte) 0x71}; final byte[] range = Arrays.copyOfRange(bytes, 2075, 2142); return bytes.length > 2142 && FileMagicNumber.indexOf(range, byte3) > 0; } @@ -1197,8 +1200,8 @@ public enum FileMagicNumber { final byte[] byte5 = new byte[]{(byte) 0xfd, (byte) 0xff, (byte) 0xff, (byte) 0xff}; final boolean flag5 = Arrays.equals(byteRange, byte5) && bytes[522] == 0x00 && bytes[523] == 0x00; final byte[] byte6 = new byte[]{(byte) 0x00, (byte) 0xb9, (byte) 0x29, (byte) 0xe8, (byte) 0x11, (byte) 0x00, (byte) 0x00, (byte) 0x00, - (byte) 0x4d, (byte) 0x53, (byte) 0x20, (byte) 0x50, (byte) 0x6f, (byte) 0x77, (byte) 0x65, (byte) 0x72, (byte) 0x50, (byte) - 0x6f, (byte) 0x69, (byte) 0x6e, (byte) 0x74, (byte) 0x20, (byte) 0x39, (byte) 0x37}; + (byte) 0x4d, (byte) 0x53, (byte) 0x20, (byte) 0x50, (byte) 0x6f, (byte) 0x77, (byte) 0x65, (byte) 0x72, (byte) 0x50, (byte) + 0x6f, (byte) 0x69, (byte) 0x6e, (byte) 0x74, (byte) 0x20, (byte) 0x39, (byte) 0x37}; final boolean flag6 = bytes.length > 2096 && Arrays.equals(Arrays.copyOfRange(bytes, 2072, 2096), byte6); return flag2 || flag3 || flag4 || flag5 || flag6; } @@ -1241,15 +1244,9 @@ public enum FileMagicNumber { WASM("application/wasm", "wasm") { @Override public boolean match(final byte[] bytes) { - return bytes.length > 7 - && Objects.equals(bytes[0], (byte) 0x00) - && Objects.equals(bytes[1], (byte) 0x61) - && Objects.equals(bytes[2], (byte) 0x73) - && Objects.equals(bytes[3], (byte) 0x6D) - && Objects.equals(bytes[4], (byte) 0x01) - && Objects.equals(bytes[5], (byte) 0x00) - && Objects.equals(bytes[6], (byte) 0x00) - && Objects.equals(bytes[7], (byte) 0x00); + return ArrayUtil.startWith(bytes, + (byte) 0x00, (byte) 0x61, (byte) 0x73, (byte) 0x6D, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00 + ); } }, /** @@ -1260,11 +1257,11 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 36 - && Objects.equals(bytes[0], (byte) 0x64) - && Objects.equals(bytes[1], (byte) 0x65) - && Objects.equals(bytes[2], (byte) 0x78) - && Objects.equals(bytes[3], (byte) 0x0A) - && Objects.equals(bytes[36], (byte) 0x70); + && Objects.equals(bytes[0], (byte) 0x64) + && Objects.equals(bytes[1], (byte) 0x65) + && Objects.equals(bytes[2], (byte) 0x78) + && Objects.equals(bytes[3], (byte) 0x0A) + && Objects.equals(bytes[36], (byte) 0x70); } }, /** @@ -1274,11 +1271,11 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { return bytes.length > 100 - && Objects.equals(bytes[0], (byte) 0x64) - && Objects.equals(bytes[1], (byte) 0x65) - && Objects.equals(bytes[2], (byte) 0x79) - && Objects.equals(bytes[3], (byte) 0x0A) && - DEX.match(Arrays.copyOfRange(bytes, 40, 100)); + && Objects.equals(bytes[0], (byte) 0x64) + && Objects.equals(bytes[1], (byte) 0x65) + && Objects.equals(bytes[2], (byte) 0x79) + && Objects.equals(bytes[3], (byte) 0x0A) && + DEX.match(Arrays.copyOfRange(bytes, 40, 100)); } }, /** @@ -1295,9 +1292,9 @@ public enum FileMagicNumber { final byte[] byte3 = new byte[]{(byte) 0x46, (byte) 0x72, (byte) 0x6F, (byte) 0x6D, (byte) 0x3A, (byte) 0x20}; final byte[] byte4 = new byte[]{(byte) 0x52, (byte) 0x65, (byte) 0x74, (byte) 0x75, (byte) 0x72, (byte) 0x6E, (byte) 0x2D, (byte) 0x50, (byte) 0x61, (byte) 0x74, (byte) 0x68, (byte) 0x3A, (byte) 0x20}; return Arrays.equals(Arrays.copyOfRange(bytes, 0, 7), byte1) - || Arrays.equals(Arrays.copyOfRange(bytes, 0, 8), byte2) - || Arrays.equals(Arrays.copyOfRange(bytes, 0, 6), byte3) - || bytes.length > 13 && Arrays.equals(Arrays.copyOfRange(bytes, 0, 13), byte4); + || Arrays.equals(Arrays.copyOfRange(bytes, 0, 8), byte2) + || Arrays.equals(Arrays.copyOfRange(bytes, 0, 6), byte3) + || bytes.length > 13 && Arrays.equals(Arrays.copyOfRange(bytes, 0, 13), byte4); } }, /** @@ -1307,7 +1304,7 @@ public enum FileMagicNumber { @Override public boolean match(final byte[] bytes) { final byte[] byte1 = new byte[]{(byte) 0x00, (byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x53, (byte) 0x74, (byte) 0x61, (byte) 0x6E, (byte) 0x64, - (byte) 0x61, (byte) 0x72, (byte) 0x64, (byte) 0x20, (byte) 0x4A, (byte) 0x65, (byte) 0x74, (byte) 0x20, (byte) 0x44, (byte) 0x42}; + (byte) 0x61, (byte) 0x72, (byte) 0x64, (byte) 0x20, (byte) 0x4A, (byte) 0x65, (byte) 0x74, (byte) 0x20, (byte) 0x44, (byte) 0x42}; return bytes.length > 18 && Arrays.equals(Arrays.copyOfRange(bytes, 0, 18), byte1); } }, @@ -1393,9 +1390,9 @@ public enum FileMagicNumber { */ public static FileMagicNumber getMagicNumber(final byte[] bytes) { final FileMagicNumber number = Arrays.stream(values()) - .filter(fileMagicNumber -> fileMagicNumber.match(bytes)) - .findFirst() - .orElse(UNKNOWN); + .filter(fileMagicNumber -> fileMagicNumber.match(bytes)) + .findFirst() + .orElse(UNKNOWN); // 压缩文档类型,如office或jar等 if (FileMagicNumber.ZIP.equals(number)) { @@ -1551,8 +1548,8 @@ public enum FileMagicNumber { } final int index = FileMagicNumber.indexOf(Arrays.copyOfRange(bytes, start, end), signature); return (index == -1) - ? -1 - : (start + index); + ? -1 + : (start + index); } // endregion }