62,626
社区成员
发帖
与我相关
我的任务
分享
package app.io;
import org.junit.Test;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @author faith.huan 2019-07-15 22:23
*/
public class FileOutputStreamTest {
@Test
public void write() throws IOException {
// 创建文件输出流,第一个参数文件路径,第二个参数是否为append模式
FileOutputStream fileOutputStream = new FileOutputStream("test.txt",true);
fileOutputStream.write("你好".getBytes());
fileOutputStream.flush();
fileOutputStream.close();
}
}
代码如上,希望可以帮到你