Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
common
Project
Project
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
曲欣亮
common
Commits
941fcaac
Commit
941fcaac
authored
Mar 05, 2020
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
762d5473
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
28 deletions
+8
-28
FileUtil.java
src/main/java/com/egolm/common/FileUtil.java
+8
-28
No files found.
src/main/java/com/egolm/common/FileUtil.java
View file @
941fcaac
...
...
@@ -14,7 +14,6 @@ import java.io.IOException;
import
java.io.InputStream
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.UnsupportedEncodingException
;
import
java.io.Writer
;
...
...
@@ -363,18 +362,23 @@ public class FileUtil {
public
static
byte
[]
streamToBytes
(
InputStream
instream
)
{
byte
[]
bytes
=
null
;
ByteArrayOutputStream
baos
=
null
;
try
{
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
(
102400
);
baos
=
new
ByteArrayOutputStream
(
102400
);
byte
[]
b
=
new
byte
[
102400
];
int
n
;
while
((
n
=
instream
.
read
(
b
))
!=
-
1
)
{
baos
.
write
(
b
,
0
,
n
);
}
instream
.
close
();
baos
.
close
();
bytes
=
baos
.
toByteArray
();
}
catch
(
Exception
e
)
{
throw
new
FileUtilException
(
"将输入流转换为字节数组异常"
,
e
);
}
finally
{
try
{
baos
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
return
bytes
;
}
...
...
@@ -549,30 +553,6 @@ public class FileUtil {
}
/**
*
* @Title: inputStreamToFile
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param ins
* @param: @param file
* @return: void
* @throws
*/
public
static
void
inputStreamToFile
(
InputStream
ins
,
File
file
)
{
try
{
OutputStream
os
=
new
FileOutputStream
(
file
);
int
bytesRead
=
0
;
byte
[]
buffer
=
new
byte
[
8192
];
while
((
bytesRead
=
ins
.
read
(
buffer
,
0
,
8192
))
!=
-
1
)
{
os
.
write
(
buffer
,
0
,
bytesRead
);
}
os
.
close
();
ins
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
static
Object
fileToObject
(
File
file
)
{
FileInputStream
fis
=
null
;
ObjectInputStream
ois
=
null
;
...
...
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