Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
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
YZG
yzg-util
Commits
bcf431d7
Commit
bcf431d7
authored
Jul 10, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SQL层级处理的支持
parent
168b544f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
7 deletions
+14
-7
FileHelper.java
...src/main/java/com/yanzuoguang/util/helper/FileHelper.java
+13
-5
ImageHelper.java
...image/src/main/java/com/yanzuoguang/util/ImageHelper.java
+1
-2
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/FileHelper.java
View file @
bcf431d7
...
@@ -16,14 +16,22 @@ public class FileHelper {
...
@@ -16,14 +16,22 @@ public class FileHelper {
/**
/**
* 获取文件类型
* 获取文件类型
*
*
* @param file 来源文件
* @param file
Path
来源文件
* @return
* @return
* @throws IOException
* @throws IOException
*/
*/
public
static
String
getMimeType
(
String
file
)
throws
IOException
{
public
static
String
getMimeType
(
String
filePath
)
{
Path
path
=
Paths
.
get
(
file
);
File
file
=
new
File
(
filePath
);
String
contentType
=
contentType
=
Files
.
probeContentType
(
path
);
if
(!
file
.
exists
())
{
return
StringHelper
.
EMPTY
;
}
Path
path
=
Paths
.
get
(
filePath
);
try
{
String
contentType
=
Files
.
probeContentType
(
path
);
return
contentType
;
return
contentType
;
}
catch
(
Exception
ex
)
{
throw
new
RuntimeException
(
"不能获取文件Mime类型"
+
filePath
,
ex
);
}
}
}
/**
/**
...
...
yzg-util-image/src/main/java/com/yanzuoguang/util/ImageHelper.java
View file @
bcf431d7
package
com
.
yanzuoguang
.
util
;
package
com
.
yanzuoguang
.
util
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.FileHelper
;
import
com.yanzuoguang.util.helper.FileHelper
;
import
net.coobird.thumbnailator.Thumbnails
;
import
net.coobird.thumbnailator.Thumbnails
;
...
@@ -37,7 +36,7 @@ public class ImageHelper {
...
@@ -37,7 +36,7 @@ public class ImageHelper {
* @return
* @return
* @throws IOException
* @throws IOException
*/
*/
public
static
int
getMediaType
(
String
file
)
throws
IOException
{
public
static
int
getMediaType
(
String
file
)
{
String
mimeType
=
FileHelper
.
getMimeType
(
file
);
String
mimeType
=
FileHelper
.
getMimeType
(
file
);
if
(
mimeType
==
null
)
{
if
(
mimeType
==
null
)
{
throw
new
RuntimeException
(
"不能识别文件类型"
+
file
);
throw
new
RuntimeException
(
"不能识别文件类型"
+
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