集册 Java实例教程 使用FileOutputStream将输出追加到文件

使用FileOutputStream将输出追加到文件

欢马劈雪     最近更新时间:2020-01-02 10:19:05

846
使用FileOutputStream将输出追加到文件
/** n o w j a v a . c o m - 时代Java 提 供 **/

import java.io.*;

 

public class Main {

 

  public static void main(String[] args) {

   

    String strFilePath = "C://Folder//demo.txt";

   

     try{

       FileOutputStream fos = new FileOutputStream(strFilePath, true);

       String strContent = "Append output to a file example";

       fos.write(strContent.getBytes());

       fos.close();

     }

     catch(FileNotFoundException ex)//来 自 nowjava - 时  代  Java

     {

      System.out.println("FileNotFoundException : " + ex);

     }

    
展开阅读全文