博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
IO流OutputStream
阅读量:4353 次
发布时间:2019-06-07

本文共 1519 字,大约阅读时间需要 5 分钟。

package outputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.OutputStream;public class Demo {            public static void main(String[] args) {            writerFile();            // System.out.println("done");        }        public static void writerFile() {            OutputStream out  =null;                        try {                /**        追加    out = new FileOutputStream("e.txt",true);                 *                  */            out = new FileOutputStream("e.txt");            String str = "helloworldaaaaaaaaa";            byte [] bs = str.getBytes();//            out.write(bs);//        out.write(bs);       和下面一样            for(byte b:bs) {                out.write(b);                                                //System.out.print((char)b);            }            out.flush();            } catch (FileNotFoundException e) {                // TODO Auto-generated catch block                e.printStackTrace();            } catch (IOException e) {                // TODO Auto-generated catch block                e.printStackTrace();            }finally {                if(out!=null) {                    try {                        out.close();                    } catch (IOException e) {                        // TODO Auto-generated catch block                        e.printStackTrace();                    }                }            }        }}

 

转载于:https://www.cnblogs.com/java-jiangtao-home/p/9374969.html

你可能感兴趣的文章
李开复有哪些地方做的不好
查看>>
12.22
查看>>
新版本的molar mass(uva-1586)明明debug过了,各种测试还是WA真是气死我了
查看>>
gdb(ddd,kdevelop等)调试ZeroIce开发的应用程序,中断信号引起的问题
查看>>
牛股助推器(每股收益率)
查看>>
SpringCloud+feign 基于Springboot2.0 负载均衡
查看>>
【BZOJ5094】硬盘检测 概率
查看>>
mac上n次安装与卸载mysql
查看>>
Python之单元测试——HTMLTestRunner
查看>>
WebNotes(PHP、css、JavaScript等)
查看>>
C++:文件的输入和输出
查看>>
Http协议、Tomcat、servlet
查看>>
Spring Boot (11) mybatis 关联映射
查看>>
macOS 下安装tomcat
查看>>
字符串格式化复习笔记
查看>>
c++ 宏定义调用不定参数的函数
查看>>
动态规划典型例题--背包问题九讲
查看>>
Qt之QHeaderView自定义排序(终极版)
查看>>
python----logging
查看>>
LBP特征 学习笔记
查看>>