package com.xia;
import java.io.*;
public class test2 { public static void main(String[] args) { //输出流 try {
FileOutputStream fos = new FileOutputStream("d:\\213.txt",true); //true 允许追加写入 String str = "\n大家下午好!天气很不错!"; // \n "转义字符" String str2 = "\n心情不错"; fos.write(str.getBytes()); //覆盖写入 fos.close(); FileInputStream fis = new FileInputStream("d:\\213.txt"); byte[] b = new byte[2048]; int i = fis.read(b); String str1 = new String(b, 0 ,i); System.out.println("读取内容 = "+ str1); fis.close(); } catch (Exception e) { e.printStackTrace();
} } }

FileOutputStream fos = new FileOutputStream("d:\\213.txt",true);

fos.write(str.getBytes());

byte[] b = new byte[2048];

int i = fis.read(b);

String str1 = new String(b, 0 ,i);

System.out.println("读取内容 = "+ str1);

fis.close();

 package com.xia;

 import java.io.*;

 public class test3 {

     public static void main(String[] args) {

         try {

             FileReader fr = new FileReader("d:\\213.txt");

             char[] c= new char[2048];

             int i = fr.read(c);

             String str = new String (c,0,i);

             System.out.println("读取内容 = " + str);

             fr.close();

         //写入

             FileWriter fw = new FileWriter("d:\\213.txt", true);

             fw.write("\n新追加的内容");

             fw.close();

         } catch (Exception e) {

             e.printStackTrace();
}
}
}

最新文章

  1. AFNetworking 3.0 源码解读(二)之 AFSecurityPolicy
  2. Laravel框架 mysql 数据库 —— 基本使用
  3. eclipse中添加python开发环境
  4. UI键盘通知
  5. bzoj3714: [PA2014]Kuglarz
  6. 各种ORM安装
  7. NFC(12)使用Android Beam技术传输文本数据及它是什么
  8. Android ListView 滚动的N种方法
  9. The run destination XXX的 iPhone is not valid for Running the scheme 'Day7通讯录Demo'.
  10. AIR学习教程(一)
  11. [2012-04-25]shell大括号参数扩展(Parameter Expansion)
  12. Codeforces Round #352 (Div. 2) (A-D)
  13. 文本在div中始终垂直居中
  14. oracle中rownum的使用
  15. Python_set集合部分功能介绍
  16. sliver
  17. Pandas 基础(12) - Stack 和 Unstack
  18. php 配置文件不加载的一次配置
  19. SDOI2017相关分析 线段树
  20. scala 爬虫 去除不能存储的特殊字符

热门文章

  1. vim多行缩进的方法
  2. [CrunchBang]禁止“桌面上鼠标滚轮切换工作区桌面“
  3. yii2添加自定义字段
  4. SVN使用(二)
  5. Openstack的ping不通实例的解决办法
  6. SQL UNION 操作符
  7. PHPCMS V9 环境搭建
  8. mysql中时间类型datetime,timestamp与int的区别
  9. C# 探索c#之Async、Await剖析
  10. 自定义Exception