Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
Overview
Overview
Details
Activity
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
yaru
fgqyxxlr
Commits
d5d7cd65
Commit
d5d7cd65
authored
Jul 27, 2018
by
RuoYi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化下载文件
parent
4d9c611a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
90 additions
and
0 deletions
+90
-0
src/main/java/com/ruoyi/common/utils/FileUtils.java
+90
-0
No files found.
src/main/java/com/ruoyi/common/utils/FileUtils.java
0 → 100644
View file @
d5d7cd65
package
com
.
ruoyi
.
common
.
utils
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileNotFoundException
;
import
java.io.IOException
;
import
java.io.OutputStream
;
/**
* 文件处理工具类
*
* @author ruoyi
*/
public
class
FileUtils
{
/**
* 输出指定文件的byte数组
*
* @param filename 文件
* @return
*/
public
static
void
writeBytes
(
String
filePath
,
OutputStream
os
)
throws
IOException
{
FileInputStream
fis
=
null
;
try
{
File
file
=
new
File
(
filePath
);
if
(!
file
.
exists
())
{
throw
new
FileNotFoundException
(
filePath
);
}
fis
=
new
FileInputStream
(
file
);
byte
[]
b
=
new
byte
[
1024
];
int
length
;
while
((
length
=
fis
.
read
(
b
))
>
0
)
{
os
.
write
(
b
,
0
,
length
);
}
}
catch
(
IOException
e
)
{
throw
e
;
}
finally
{
if
(
os
!=
null
)
{
try
{
os
.
close
();
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
}
}
if
(
fis
!=
null
)
{
try
{
fis
.
close
();
}
catch
(
IOException
e1
)
{
e1
.
printStackTrace
();
}
}
}
}
/**
* @Desc 删除文件
* @param filePath 文件
* @return
*/
public
static
boolean
deleteFile
(
String
filePath
)
{
boolean
flag
=
false
;
File
file
=
new
File
(
filePath
);
// 路径为文件且不为空则进行删除
if
(
file
.
isFile
()
&&
file
.
exists
())
{
file
.
delete
();
flag
=
true
;
}
return
flag
;
}
}
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