简单实现IO读写

来源:互联网 发布:中海达rtk数据导出 编辑:程序博客网 时间:2024/06/05 22:39

前言

    java利用封装好的jar包,实现IO读写操作。

内容

需求

    将indome里面的文字,读取并且写入到outdemo文件中

demo

/** * Created by zhou on 2017/3/8. */public class MyIoDemo {    public static void main (String args[]) throws IOException{        FileInputStream in = null;        FileOutputStream out = null;        try {            //notice this "//"            in = new FileInputStream("//C://Users//zhou//Desktop//indemo.txt");            out = new FileOutputStream("//C://Users//zhou//Desktop//outdemo.txt");            int c;            while ((c = in.read()) != -1) {                out.write(c);            }            System.out.println(out);            System.out.println("success!");        }finally {            {                if(in != null) {                    in.close();                }                if (out != null) {                    out.close();                }            }        }    }}

效果图


小结

    革命尚未成功,还得努力啊!


感谢您的宝贵时间···

0 0
原创粉丝点击