forked from admin862/CDO
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
KenelLiu
authored and
KenelLiu
committed
Jul 11, 2017
1 parent
5b0f322
commit 3fc9e65
Showing
5 changed files
with
109 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
CDOUtil/src/main/java/com/cdo/util/common/BytesStream.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.cdo.util.common; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import com.cdo.util.constants.Constants; | ||
|
||
public class BytesStream { | ||
|
||
public static byte[] readStream(InputStream in) throws IOException{ | ||
try{ | ||
ByteArrayOutputStream out=new ByteArrayOutputStream(); | ||
byte[] buf = new byte[Constants.Byte.defaultSize]; | ||
int len; | ||
while ((len = in.read(buf)) > 0) { | ||
out.write(buf, 0, len); | ||
} | ||
return out.toByteArray(); | ||
}catch(Exception ex){ | ||
throw new IOException(ex.getMessage(), ex); | ||
}finally{ | ||
if(in!=null){try{ in.close();}catch(Exception ex){}} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters