首页 > 其他 > 详细

IO流

时间:2019-06-16 17:27:59      阅读:115      评论:0      收藏:0      [点我收藏+]
package three;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

public class IO {

    public static void main(String[] args) {
        File file = new File("data.txt");
        System.out.println("路径:"+file.getAbsolutePath());
        try {
            FileOutputStream out = new FileOutputStream(file);
            byte[] str = "12345abcdef@#%&*软件工程".getBytes();
            out.write(str);
            out.close();
        }catch(Exception e) {
            e.printStackTrace();
        }
        try {
            FileInputStream in = new FileInputStream(file);
            byte[] str1 = new byte[100];
            int length = in.read(str1);
            System.out.println("文件中的信息是:"+ new String(str1,0,length));
            in.close();
        }catch(Exception e) {
            e.printStackTrace();
        }
    }
}

技术分享图片

 技术分享图片

 

IO流

原文:https://www.cnblogs.com/zhangkaiz/p/11032172.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!