集册 Java实例教程 使用FileOutputStream将字节数组写入文件

使用FileOutputStream将字节数组写入文件

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

475
使用FileOutputStream将字节数组写入文件

/**
 * N o w  J a v a  .   c o m 提 供 
**/

import java.io.*;

 

public class Main {

 

  public static void main(String[] args) {

   

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

   

     try

     {

       FileOutputStream fos = new FileOutputStream(strFilePath);

       String strContent = "Write File using Java FileOutputStream example !";

       fos.write(strContent.getBytes());

       fos.close();

     

     }

     catch(FileNotFoundException ex)
     /*
     N o w J a v a . c o m
     */

     {

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

     
展开阅读全文