java标准的IO操作,Input,Output输入与输出
public static void main(String[] args) throws IOException {
/*
* 向文件fos.txt中写出字符串
* 流有两种常见创建形式:
* FileOutputStream(String path)
* FileOutputSteam(File file)
* 以上两种创建的是覆盖写模式,即若要操作文件已经存在,会先将文件数据清除,然后通过该流
* 写出的数据作为该文件数据
*
* FileOutputStream(String path,boolean append)
* FileOutputSteam(File file,boolean append)
* 当第二个参数为true时,该流为追加写模式,即该文件原有数据全部保留
* 通过流写出的数据会被追加到文件后面继续写
*
*/
FileOutputStream fos=new FileOutputStream("fos.txt");
String str="up好忙";
fos.write(str.getBytes("UTF-8"));
System.out.println("写出完毕");
fos.close();
}