• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
静风铃
博客园    首页    新随笔    联系   管理    订阅  订阅

0927-练习

 1 public class TextRw {
 2 
 3     public static void main(String[] args) {
 4         // 编写TextRw的文件
 5         try 
 6         {
 7             FileWriter fw=new FileWriter("C:/Users/Administrator/Desktop/zuoye1.txt");
 8             fw.write("小二逼,66666");
 9             fw.close();
10             System.out.println("写入成功");
11             FileReader fr=new FileReader("C:/Users/Administrator/Desktop/zuoye1.txt");
12             char[]nb=new char[1024];
13             int i=0;
14             StringBuilder sb=new StringBuilder();
15             while((i=fr.read(nb))>0)
16             {
17                 sb.append(nb, 0, i);
18             }
19             fr.close();
20             System.out.println("读取="+sb);
21             System.out.println("读取成功");
22             
23         } 
24         catch (IOException e) 
25         {
26             e.printStackTrace();
27         }            

 

posted @ 2016-09-27 20:28  静风铃  阅读(146)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3