-
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.
Merge branch 'developer' of github.com:qiniu/java-sdk into linking
- Loading branch information
Showing
6 changed files
with
144 additions
and
49 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.qiniu.util; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.ByteArrayOutputStream; | ||
|
||
public class IOUtils { | ||
|
||
private static final int DEFAULT_BUFFER_SIZE = 1024 * 4; | ||
|
||
/** | ||
* 输入InputSteam,返回byte[]. | ||
* 参考:https://github.com/apache/commons-io/blob/master/src/main/java/org/apache/commons/io/IOUtils.java<br> | ||
* @param input | ||
* @return | ||
* @throws IOException | ||
*/ | ||
public static byte[] toByteArray(final InputStream input) throws IOException { | ||
try (final ByteArrayOutputStream output = new ByteArrayOutputStream()) { | ||
byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; | ||
int n; | ||
while (-1 != (n = input.read(buffer))) { | ||
output.write(buffer, 0, n); | ||
} | ||
return output.toByteArray(); | ||
} | ||
} | ||
|
||
} |
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