java 写入、读取txt
2015-11-04 11:31
519 查看
写入:
读取:
<span style="font-size:18px;">FileWriter fw = new FileWriter("d://test.txt", true); fw.write("aaaaaa"); fw.close();</span>
读取:
<span style="font-size:18px;"> String encoding = "GBK"; File file = new File(filePath); if (file.isFile() && file.exists()) { InputStreamReader read = new InputStreamReader(new FileInputStream(file), encoding); BufferedReader bufferedReader = new BufferedReader(read); String lineTxt = null; while ((lineTxt = bufferedReader.readLine()) != null) { System.out.println(lineTxt); } read.close(); } else { System.out.println("找不到指定的文件"); }</span>
相关文章推荐
- Eclipse automatically build
- spring mvc与Mybatis整合——(一)基础入门--概览
- javax.servlet.jsp.PageContext cannot be resolved to a type的解決之道
- java 文件流
- java数据类型和mysql数据类型对应表
- Java中的向上转型与向下转型
- eclipse 部署 Bug
- 从”JAVA“而终 10:javaAPI(二)Math、System类
- 声明对象和实例化对象的区别
- java 追加写入代码一例
- JVM学习笔记
- 【Java】【Flume】Flume-NG启动过程源码分析(二)
- Java Main如何被执行?
- spring数据库读写分类实现方式(现公司使用方式)
- Spring中配置和读取多个Properties文件-- PropertyPlaceholderConfigurer
- 一站式解决eclipse genymotion插件问题
- JAVA托盘程序SystemTray的心得
- spring mvc controller间跳转 重定向 传参
- 使用spring-mvc 框架返回json格式数据 报406
- avoid duplicate submission 结合spring-mvc的防重复提交