Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李丛阳
education
Commits
d85f3c1f
Commit
d85f3c1f
authored
Dec 20, 2019
by
luzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
e0962de5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
CheckFileHeaderUtil.java
src/main/java/org/rcisoft/core/util/CheckFileHeaderUtil.java
+23
-13
No files found.
src/main/java/org/rcisoft/core/util/CheckFileHeaderUtil.java
View file @
d85f3c1f
...
...
@@ -20,32 +20,42 @@ public class CheckFileHeaderUtil {
return
stringBuilder
.
toString
();
}
public
String
toCheck
(
String
url
){
/**
* 通过本地地址去判断文件类型
* @param url
* @return
*/
public
boolean
toCheck
(
String
url
){
String
result
=
""
;
try
{
FileInputStream
is
=
new
FileInputStream
(
url
);
byte
[]
b
=
new
byte
[
3
];
byte
[]
b
=
new
byte
[
45
];
is
.
read
(
b
,
0
,
b
.
length
);
result
=
this
.
checkType
(
bytesToHexString
(
b
).
toUpperCase
());
is
.
close
();
}
catch
(
Exception
e
){
log
.
debug
(
e
.
getMessage
());
}
return
result
;
if
(
result
.
toUpperCase
().
contains
(
url
.
substring
(
url
.
lastIndexOf
(
"."
)+
1
).
toUpperCase
())){
return
true
;
}
else
{
return
false
;
}
}
public
static
String
checkType
(
String
type
)
{
switch
(
type
)
{
case
"504B03"
:
return
"pptx、docx"
;
case
"D0CF11"
:
return
"ppt、doc"
;
case
"494433"
:
return
"mp3"
;
case
"255044"
:
return
"pdf"
;
case
"FFD8FF"
:
return
"jpg"
;
case
"89504E"
:
return
"png"
;
case
"474946"
:
return
"gif"
;
case
"000000"
:
return
"mp4"
;
case
"524946"
:
return
"avi"
;
case
"E783A6"
:
return
"txt"
;
case
"504B030414000600080000002100DFCC18F5AD010000460C0000130008025B436F6E74656E745F54797065735D"
:
return
"pptx"
;
case
"504B0304140006000800000021004ABC02716D01000028060000130008025B436F6E74656E745F54797065735D"
:
return
"docx"
;
case
"D0CF11E0A1B11AE1000000000000000000000000000000003E000300FEFF090006000000000000000000000001"
:
return
"doc"
;
case
"D0CF11E0A1B11AE1000000000000000000000000000000003E000300FEFF090006000000000000000000000003"
:
return
"ppt"
;
case
"4944330300000000054054414C420000000100000054594552000000010000005452434B000000010000005443"
:
return
"mp3"
;
case
"255044462D312E350D0A25B5B5B5B50D0A312030206F626A0D0A3C3C2F547970652F436174616C6F672F506167"
:
return
"pdf"
;
case
"FFD8FFE000104A46494600010101004800480000FFDB0043000302020302020303030304030304050805050404"
:
return
"jpg"
;
case
"89504E470D0A1A0A0000000D49484452000000EC000000880806000000E4B6075800000006624B474400FF00FF"
:
return
"png"
;
case
"000000206674797069736F6D0000020069736F6D69736F32617663316D70343100000008667265650014359C6D"
:
return
"mp4"
;
case
"E783A6E783A6E783A6E783A6E783A6E783A6E783A6E783A6E783A6E783A6E783A6E783A6E783A6E783A6E783A6"
:
return
"txt"
;
case
"504B0304140000000800A473374F5424F3E6576D09003D5C0B0008000000746573742E6D703444597540144D1B"
:
return
"zip"
;
default
:
return
"other"
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment