package com.czie.iot1913.lps01.IO.ioTest.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @author 1944900433@qq.com
* @date 2022-03-22 21:25
* void write(byte[] b)
* 写 b.length字节从指定的字节数组来此文件输出流。
* void write(byte[] b, int off, int len)
* 写 len字节指定字节数组中的起始偏移 off此文件输出流。
* void write(int b)
* 将指定的字节写入该文件输出流中。
*/
public class FileOutPutStreamDemo02 {
public static void main(String[] args) throws IOException {
FileOutputStream fos01 = new FileOutputStream("myList\\fos.txt");
//new File(name)
// File file = new File("myList\\fos.txt");
// FileOutputStream fos2 = new FileOutputStream(file);
// FileOutputStream fos2 = new FileOutputStream(new File("myList\\fos.txt"));
// * void write(int b)
// * 将指定的字节写入该文件输出流中。
// fos01.write(97);
// fos01.write(98);
// fos01.write('a');
// fos01.write('b');
//* void write(byte[] b)
// * 写 b.length字节从指定的字节数组来此文件输出流。
// byte [] bytes={97,98,99,'a'};
// fos01.write(bytes);
//String s="刘品水大帅锅";
//byte[] bytes = s.getBytes();
//fos01.write(bytes);
// * void write(byte[] b, int off, int len)
// * 写 len字节指定字节数组中的起始偏移 off此文件输出流。
String s1="abcdefghijk";
fos01.write(s1.getBytes(),1,5);
fos01.close();
//释放资源!!!
}
}
![]()