如何把byte转换成inputstream
2个回答
2016-01-01
展开全部
1、将File、FileInputStream 转换为byte数组:
File file = new File("file.txt");
InputStream input = new FileInputStream(file);
byte[] byt = new byte[input.available()];
input.read(byt);
2、将byte数组转换为InputStream:
byte[] byt = new byte[1024];
InputStream input = new ByteArrayInputStream(byt);
3、将byte数组转换为File:
File file = new File('');
OutputStream output = new FileOutputStream(file);
BufferedOutputStream bufferedOutput = new BufferedOutputStream(output);
bufferedOutput.write(byt);
File file = new File("file.txt");
InputStream input = new FileInputStream(file);
byte[] byt = new byte[input.available()];
input.read(byt);
2、将byte数组转换为InputStream:
byte[] byt = new byte[1024];
InputStream input = new ByteArrayInputStream(byt);
3、将byte数组转换为File:
File file = new File('');
OutputStream output = new FileOutputStream(file);
BufferedOutputStream bufferedOutput = new BufferedOutputStream(output);
bufferedOutput.write(byt);
2016-01-01 · 知道合伙人互联网行家
关注
展开全部
代码如下
FileInputStream instream = new FileInputStream(filename);
byte[] k=new byte[1024*1024*20];
int bloblength=instream.read(k);
byte[] blobparam=new byte[bloblength];
instream = new FileInputStream(filename);
instream.read(blobparam,0,blobparam.length);
FileInputStream instream = new FileInputStream(filename);
byte[] k=new byte[1024*1024*20];
int bloblength=instream.read(k);
byte[] blobparam=new byte[bloblength];
instream = new FileInputStream(filename);
instream.read(blobparam,0,blobparam.length);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询