62,614
社区成员
发帖
与我相关
我的任务
分享
InputStream input = new FileInputStream("c:\\1.text");
byte[] readBuffer = new byte[input.available()];
int len=input.read(readBuffer);
int total=0;
while(total<readBuffer.length) {
total+= len;
input.read(readBuffer, total, readBuffer.length-total);
}
input.close();
InputStream is = new FileInputStream("c:\\1.text");//或从其他地方获取的输入流
ByteArrayOutputStream baos= new ByteArrayOutputStream();
int read =-1;
while( -1 !=(read =is.read()))
{
baos.write(read);
}
byte[] array = baos.toByteArray();
baos.close();
is.close();