/**
* author : lipan
* filename : StreamUtils.java
* create_time : 2014年8月28日 下午5:55:06
*/
package com.sets.speedtest.utils;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
/**
* @author : lipan
* @create_time : 2014年8月28日 下午5:55:06
* @desc : Stream Utils
* @update_person:
* @update_time :
* @update_desc :
*
*/
public class StreamUtils
{
/**
* 输入流转字节数组
* @param in
* @return
* @throws Exception
*/
public static byte[] getBytes(InputStream in) throws Exception
{
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int n;
while ((n = in.read(b)) != -1)
{
out.write(b, 0, n);
}
in.close();
return out.toByteArray();
}
}