List<InstorageNoticeDto> noticeList = null;

        FileOutputStream fos = null;
FileInputStream is = null;
File file = new File(myfile.getOriginalFilename());
int ch = 0;
try
{
is = (FileInputStream) myfile.getInputStream();
fos = new FileOutputStream(file);
while ((ch = is.read()) != -1)
{
fos.write(ch);
}
} catch (IOException e1)
{
throw new Exception("文件导入失败,失败原因:" + e1.getMessage());
} finally
{
try
{
fos.flush();
fos.close();
} catch (IOException e)
{
throw new Exception("文件导入失败,失败原因:" + e.getMessage());
}
}

这样通过int值把InputStream流改成OutputStream流完成,不必考虑通过字节数组的长度问题

FileOutputStream与FileInputStream互相转换的更多相关文章

  1. Java IO流 FileOutputStream、FileInputStream的用法

    FileOutputStream.FileInputStream的使用 FileOutputStream是OutputStream的继承类,它的主要功能就是向磁盘上写文件.FileOutputStre ...

  2. Java IO流 FileOutputStream、FileInputStream的用法   

    FileOutputStream.FileInputStream的使用 FileOutputStream是OutputStream的继承类,它的主要功能就是向磁盘上写文件.FileOutputStre ...

  3. FileOutputStream和FileInputStream的用法

    public static void show() { File f=new File("d:"+File.separator+"1.txt"); FileOu ...

  4. Java中FileOutputStream和FileInputStream使用例子

    package a.ab; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.F ...

  5. FileOutputStream和FileInputStream

    package one.string; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFound ...

  6. Java IO 之 FileInputStream & FileOutputStream源码分析

    Writer      :BYSocket(泥沙砖瓦浆木匠) 微         博:BYSocket 豆         瓣:BYSocket FaceBook:BYSocket Twitter   ...

  7. java io系列07之 FileInputStream和FileOutputStream

    本章介绍FileInputStream 和 FileOutputStream 转载请注明出处:http://www.cnblogs.com/skywang12345/p/io_07.html File ...

  8. JAVA基础学习day22--IO流四-对象序列化、管道流、RandomAccessFile、DataStream、ByteArrayStream、转换流的字符编码

    一.对象序列化 1.1.对象序列化 被操作的对象需要实现Serializable接口 1.2.对象序列化流ObjectOutputStream与ObjectInputStream ObjectInpu ...

  9. IO流(6)—转换流

    1.处理流之二:转换流 InputStreamReader和OutputStreamWriter 2.当作用的文件就是一个文本文件且使用字节流传输时,需要把它转换成字符流,再在外面加上缓冲流以加速传输 ...

随机推荐

  1. tuple内部方法

    代码: #tuple内部方法 ac=('a','r','6','d','a','b','b','e') print(dir(ac)) print(ac.count('a')) print(ac.ind ...

  2. BZOJ-1934 Vote 善意的投票 最大流+建图

    1934: [Shoi2007]Vote 善意的投票 Time Limit: 1 Sec Memory Limit: 64 MB Submit: 1551 Solved: 951 [Submit][S ...

  3. POJ 1466 Girls and Boys

    Girls and Boys Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://poj.org/problem?id=1466 Descripti ...

  4. 关于clonezilla

    Clonezilla 是一个很好的系统克隆工具,它可以说是吸取了 Norton Ghost 和 Partition Image 的优点.即不仅支持对整个系统进行克隆,而且也可以克隆单个的分区,这种灵活 ...

  5. OracleOraDb10g_home1TNSListener无法启动

    1:“本地计算机上的OracleOraDb10g_home1TNSListener服务启动后停止.某些服务在未由其他服务或程序使用时将自动停止.” 解决办法:动态ip,服务 OracleOraDb10 ...

  6. STL Iterators

    Summary of Chapter 33 STL Iterators from The C++ Programming Language 4th. Ed., Bjarne Stroustrup. - ...

  7. POJ 2752 Seek the Name, Seek the Fame

    传送门 Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 14761   Accepted: 7407 Description ...

  8. POJ3259Wormholes(判断是否存在负回路)

    Wormholes Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 38300   Accepted: 14095 Descr ...

  9. c++ 类型安全

    类型安全很大程度上可以等价于内存安全,类型安全的代码不会试图访问自己没被授权的内存区域.“类型安全”常被用来形容编程语言,其根据在于该门编程语言是否提供保障类型安全的机制:有的时候也用“类型安全”形容 ...

  10. IOS学习笔记—苹果推送机制APNs

    转自:唐韧_Ryan http://blog.csdn.net/ryantang03/article/details/8482259 推送是解决轮询所造成的流量消耗和 电量消耗的一个比较好的解决方案, ...