FileOutputStream

使用FileOutputStream可以向文件写入内容。如果在构造FileOutputStream时,该文件已经存在,那么就覆盖这个文件。

代码
public static void main(String[] args) throws IOException {

String path
= System.getProperty("user.dir") + File.separator + "temp.txt";

File file
= new File(path);

OutputStream os
= new FileOutputStream(file);

os.write(
"OutputStream".getBytes());

os.flush();

os.close();
}

 

相关文章:

  • 2021-10-24
  • 2021-09-08
  • 2021-09-29
  • 2022-12-23
  • 2022-01-10
  • 2021-05-22
猜你喜欢
  • 2022-02-08
  • 2021-10-05
  • 2021-10-30
  • 2021-08-04
  • 2022-02-11
相关资源
相似解决方案