Java IO之字符流
2024-08-22 14:20:27
public static void main(String[] args) { FileWriter fw = null; try { fw = new FileWriter("/Users/weianlai/demo"); fw.write("这是一个demo"); fw.flush(); } catch (IOException e) { e.printStackTrace(); } finally { if (fw != null) { try { fw.close(); } catch (IOException e) { e.printStackTrace(); } } } FileReader fr = null; try { fr = new FileReader("/Users/weianlai/demo"); char[] buf = new char[1024]; int num = 0; while ((num = fr.read(buf)) != -1) { System.out.println(new String(new String(buf, 0, num))); } } catch (Exception e) { e.printStackTrace(); } finally { if (fr != null) { try { fr.close(); } catch (IOException e) { e.printStackTrace(); } } } }
最新文章
- vs2010统计项目代码总行数
- 数据库视图 (View)和EntityFramework Code First结合使用
- 移动前端页面与Chrome的远程真机调试
- Why NHibernate updates DB on commit of read-only transaction
- [Bhatia.Matrix Analysis.Solutions to Exercises and Problems]ExI.3.6
- Sass函数--字符串函数
- apache2.4.x三种MPM介绍
- oracle习题1~13
- MapReduce运行流程分析
- Angular - Templates(模板)
- golang实现权重轮询调度算法
- sql中的常见报错;
- easyui-combobox的option选项为true与false时的问题
- Subarray Sums Divisible by K LT974
- 2019.01.09 bzoj2599: [IOI2011]Race(点分治)
- 系统启动时队列自动下单--ServletContextListener
- 怪奇物语第二季/全集Stranger Things迅雷下载
- DataFrame在算术方法中填充值
- OpenNI检测不到Kinect Camera和Kinect Audio了
- Linux 批量管理工具