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
93dd46ff
Commit
93dd46ff
authored
Dec 20, 2019
by
luzhuang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
d85f3c1f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
3 deletions
+8
-3
CheckFileHeaderUtil.java
src/main/java/org/rcisoft/core/util/CheckFileHeaderUtil.java
+3
-3
FileReadableUtil.java
src/main/java/org/rcisoft/core/util/FileReadableUtil.java
+5
-0
No files found.
src/main/java/org/rcisoft/core/util/CheckFileHeaderUtil.java
View file @
93dd46ff
...
@@ -25,16 +25,16 @@ public class CheckFileHeaderUtil {
...
@@ -25,16 +25,16 @@ public class CheckFileHeaderUtil {
* @param url
* @param url
* @return
* @return
*/
*/
public
boolean
toCheck
(
String
url
){
public
static
boolean
toCheck
(
String
url
){
String
result
=
""
;
String
result
=
""
;
try
{
try
{
FileInputStream
is
=
new
FileInputStream
(
url
);
FileInputStream
is
=
new
FileInputStream
(
url
);
byte
[]
b
=
new
byte
[
45
];
byte
[]
b
=
new
byte
[
45
];
is
.
read
(
b
,
0
,
b
.
length
);
is
.
read
(
b
,
0
,
b
.
length
);
result
=
this
.
checkType
(
bytesToHexString
(
b
).
toUpperCase
());
result
=
checkType
(
bytesToHexString
(
b
).
toUpperCase
());
is
.
close
();
is
.
close
();
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
log
.
debug
(
e
.
getMessage
());
log
.
error
(
e
.
getMessage
());
}
}
if
(
result
.
toUpperCase
().
contains
(
url
.
substring
(
url
.
lastIndexOf
(
"."
)+
1
).
toUpperCase
())){
if
(
result
.
toUpperCase
().
contains
(
url
.
substring
(
url
.
lastIndexOf
(
"."
)+
1
).
toUpperCase
())){
return
true
;
return
true
;
...
...
src/main/java/org/rcisoft/core/util/FileReadableUtil.java
View file @
93dd46ff
...
@@ -84,6 +84,11 @@ public class FileReadableUtil {
...
@@ -84,6 +84,11 @@ public class FileReadableUtil {
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
log
.
error
(
"关闭 InputStream 输出流错误!"
,
e
);
log
.
error
(
"关闭 InputStream 输出流错误!"
,
e
);
}
}
if
(!
CheckFileHeaderUtil
.
toCheck
(
path
)){
throw
new
ServiceException
(
ResultServiceEnums
.
FILE_UNREADABLE
);
}
}
}
public
File
TXTHandler
(
File
file
)
{
public
File
TXTHandler
(
File
file
)
{
...
...
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