IO流 不用生成文件
2015-06-29 11:02
197 查看
InputStream fin = new ByteArrayInputStream(content);
OutputStream baos = new ByteArrayOutputStream();
byte[] content = baos.toByteArray();
文件的读写
byte[] in2b = null;
ByteArrayOutputStream swapStream = null;
InputStream fis = null;
String filePath = "";
try {
filePath = "D://bpm.docx";
fis = new FileInputStream(new File(filePath));
swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[1024];
int rc = 0;
while ((rc = fis.read(buff, 0, 1024)) > 0) {
swapStream.write(buff, 0, rc);
}
in2b = swapStream.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
fis.close();
swapStream.close();
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return in2b;
OutputStream baos = new ByteArrayOutputStream();
byte[] content = baos.toByteArray();
文件的读写
byte[] in2b = null;
ByteArrayOutputStream swapStream = null;
InputStream fis = null;
String filePath = "";
try {
filePath = "D://bpm.docx";
fis = new FileInputStream(new File(filePath));
swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[1024];
int rc = 0;
while ((rc = fis.read(buff, 0, 1024)) > 0) {
swapStream.write(buff, 0, rc);
}
in2b = swapStream.toByteArray();
} catch (Exception e) {
e.printStackTrace();
}finally{
try {
fis.close();
swapStream.close();
fis.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return in2b;
相关文章推荐
- java IO流文件的读写具体实例
- 装饰类设计模式 【不完善版】 IO流
- IO流操作规律 转码
- 重置标准输入输出流 IO流
- 【Java基础】IO流操作
- IO(输入输出流) 4000
- IO流操作规律(一)
- 黑马程序员————————IO流 FileWriter类 和 FileReader类的一些基本用法
- 黑马程序员--Java基础--IO流
- io 学习
- 黑马程序员—装箱拆箱与IO流重点
- 黑马程序员——java基础——IO流(2)File类,IO常用流对象及IO包中其他类
- 黑马程序员_java中IO流的操作规律
- 参加某培训机构Java培训记录(七)
- 黑马程序员——Java IO字符流、字节流(小练习)
- 黑马程序员——Java 对象序列化
- 黑马程序员—IO学习笔记
- 黑马程序员—IO流复制练习
- 黑马程序员_IO流
- 黑马程序员——IO笔记 第十三篇