IO流——文件操作流之字节输出流FileOutputStream
2016-08-15 11:01
357 查看
package com.qianfeng.demo04; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; //向文件当中写入数据 public class FileOutputStreamDemo { public static void main(String[] args) { FileOutputStream fos = null; try { //1.创建一个文件输出字节流对象 fos = new FileOutputStream(new File("c:/aa.txt"),true); //2.准备数据源,并且将数据源转化为字节数组。 String str = "温柔可爱美丽大方和善端庄有智慧"; //3.将字节数组写入到输出流当中。 fos.write(str.getBytes()); //4.刷新输出流 fos.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { if (fos!=null) { try { //5.关闭流 fos.close(); } catch (IOException e) { e.printStackTrace(); } } } } }
相关文章推荐
- java笔记→IO流中字节,字符的输入与输出(文件)
- IO流——文件操作流之字节输入流FileInputStream
- c文件操作,兼容多字节和unicode
- Perl文件操作_输出到文件
- 对一个文件的写入写出操作--IO流
- 用script命令记录终端的操作和输出信息到文件
- android 文件输出操作详解
- Hibernate 对数据库Blob图片的查询操作---页面显示图片,文件的输出
- IO流文件读操作
- 厚积薄发JAVA文件操作--java I/O中通过字符流读取文件并输出
- C++中的文件输入输出操作
- IO流的基本操作规律以及利用IO流实现音频文件的切割与合并
- 数据库操作_连接SQL Server数据库示例;连接ACCESS数据库;连接到 Oracle 数据库示例;SqlCommand 执行SQL命令示例;SqlDataReader 读取数据示例;使用DataAdapter填充数据到DataSet;使用DataTable存储数据库表;将数据库数据填充到 XML 文件;10 使用带输入参数的存储过程;11 使用带输入、输出参数的存储过程示;12 获得数据库中表的数目和名称;13 保存图片到SQL Server数据库示例;14 获得插入记录标识号;Exce
- 文件的输入输出与假加密——略析JAVA的IO流
- JS/VBS配合Adodb.Stream处理字节数据/输出二进制文件
- .NET Framework-垃圾回收器实现内存的分配、释放,文件的操作和IO流
- php对csv文件的读取,写入,输出下载操作
- 对Xml的文件操作,根据数据的配置和数据样式的定义,将结果字符输出
- IO流操作与文件File操作
- 一个模拟页面操作,解析xml输出,生成CSV文件的ruby程­序