JAVA中 byte[]数组如何转为InputStream
2016-06-10 23:38
323 查看
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);
相关文章推荐
- java 8 之Streams 解说
- Java内存模型
- Java正则表达式:Pattern类和Matcher类
- Java线程池
- 设计模式—模板设计模式
- eclipse maven install报错解决
- JavaSE复习_3 继承
- java8十大新特性浅谈
- Exception in thread "main" java.lang.RuntimeException: job failed: name=inject urls, jobid=job_local
- 专2-第二课 Eclipse开发环境搭建
- Spring创建对象的方式3种方式
- Java多线程中的生产者消费者模型
- java计算日期相差的天、时、分、秒
- struts2拦截器与过滤器
- struts2原理
- 梳理spring篇-Aop机制
- JavaAPI之AtomicInteger
- JavaI/O(一)--字符流
- 基于spring的文件上传--单文件上传
- Java(数据类型,数组表达,Unicode编码)