io流的字节的读取和写入

写一个简单的写入和读取

读取

package contorller;

import java.io.FileOutputStream;
import java.io.IOException;

public class ZIj {
    public static void main(String []args) throws IOException {
        FileOutputStream f=new FileOutputStream("d:/w.txt",true);
        f.write(1);
        f.write(2);
        f.flush();
    }
}

结果

1
2

写入

package contorller;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class RZIJ {
    public static void main(String[]args) throws IOException {
        FileInputStream f=new FileInputStream("d:/w.txt");
        int b=f.read();
        int c=f.read();
        System.out.println(b);
        System.out.println(c);

    }
}

这上面只是我的简单写法,利用字节数组是一样的意思

 

 

posted @   码海兴辰  阅读(20)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 如何调用 DeepSeek 的自然语言处理 API 接口并集成到在线客服系统
点击右上角即可分享
微信分享提示