前提:记事本里面一共有605个字

1.使用BufferedReader和FileReader来读取txt里面的内容,用时相对短。读完记得关闭流br.close()

2.指定UTF-8输出格式,使用FileInputStream,InputStreamReaderBufferedReader,时间也是瞬间,读完记得关闭流isr.close()和bf.close()

3.使用commons.io里面的FileUtils.lineIterator来读取文件,时间也是一秒。。lineIterator.close()

可到这里下载需要的commons.io文件:https://commons.apache.org/proper/commons-io/download_io.cgi

4将EXAMPLE_TXT_PATH_WRINT的内容写到EXAMPLE_TXT_PATH_READ文件里面

通过ByteArrayInputStream、ByteArrayOutputStream、TeeInputStream直接对字节来进行读写。。

XmlStreamReader来读取文件的字符格式

api:https://commons.apache.org/proper/commons-io/javadocs/api-2.0.1/index.html?org/apache/commons/io/LineIterator.html

.IOCase判断某个字符串中是否以另一个字符串结尾,并且区分大小写

api:https://commons.apache.org/proper/commons-io/javadocs/api-2.0.1/index.html?org/apache/commons/io/LineIterator.html

package content.demo;

import org.apache.commons.io.IOCase;
import org.junit.Test; import java.io.IOException; /**
* Created by 70486 on 2017/6/28 on 21:59.
*/ public class testDemo3 { @Test
public void setStart() throws IOException { String str1 = "This is a new String.";
String str2 = "This is another new String, yes!"; //SYSTEM :由当前操作系统确定的区分大小写的常数。
//checkEndsWith:使用区分大小写的规则检查一个字符串是否以另一个字符串结尾。
System.out.println("以字符串结尾(由系统区分大小写)Ends with string (case sensitive): " +
IOCase.SYSTEM .checkEndsWith(str1, "string")); System.out.println("以字符串结尾(由系统区分大小写)Ends with string (case sensitive): " +
IOCase.SYSTEM .checkEndsWith(str2, "yes")); //SENSITIVE:无论操作系统如何,区分大小写的常数。
//checkEndsWith:使用区分大小写的规则检查一个字符串是否以另一个字符串结尾。
System.out.println("以字符串结尾(区分大小写)Ends with string (case sensitive): " +
IOCase.SENSITIVE.checkEndsWith(str1, "string.")); System.out.println("以字符串结尾(区分大小写)Ends with string (case sensitive): " +
IOCase.SENSITIVE.checkEndsWith(str2, "yes!")); //INSENSITIVE:无论操作系统如何,不区分大小写的常数。
//checkEndsWith:使用区分大小写的规则检查一个字符串是否以另一个字符串结尾。
System.out.println("以字符串结尾(不区分大小写)Ends with string (case insensitive): " +
IOCase.INSENSITIVE.checkEndsWith(str1, "string.")); System.out.println("以字符串结尾(不区分大小写)Ends with string (case insensitive): " +
IOCase.INSENSITIVE.checkEndsWith(str2, "yes!"));
}
}

java io流读取 和commons.io的使用的更多相关文章

  1. java IO流读取图片供前台显示

    最近项目中需要用到IO流来读取图片以提供前台页面展示,由于以前一直是用url路径的方式进行图片展示,一听说要项目要用IO流读取图片感觉好复杂一样,但任务下达下来了,做为程序员只有选择去执行喽,于是找了 ...

  2. Java (三)APACHE Commons IO 常规操作

    上一篇:Java (二)基于Eclipse配置Commons IO的环境 例1:查看文件.文件夹的长度(大小). 1 import java.io.File; 2 3 import org.apach ...

  3. Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FileUtils

    1.错误叙述性说明 警告: Could not create JarEntryRevision for [jar:file:/D:/MyEclipse/apache-tomcat-7.0.53/web ...

  4. java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream(转)

    java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream 使用Tomcat的Manag ...

  5. java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream

    java.lang.ClassNotFoundException: org.apache.commons.io.output.DeferredFileOutputStream at org.apach ...

  6. Tomcat中使用commons-io-2.5发生的错误java.lang.ClassNotFoundException: org.apache.commons.io.IOUtils

    关键词:IntelliJ IDEA.Tomcat.commons-io-2.5.jar.java.lang.ClassNotFoundException: org.apache.commons.io. ...

  7. 报错:maven:java.lang.NoClassDefFoundError: org/apache/commons/io/Charsets

    运行报错: maven:java.lang.NoClassDefFoundError: org/apache/commons/io/Charsets 找不到Charsets这个类 上网查了以后,是因为 ...

  8. java.lang.NoClassDefFoundError: org/apache/commons/io/output/DeferredFileOutputStream异常解决方法

    使用Tomcat部署Servlet程序时,单步调试跟踪到: List<FileItem> itemList = sfu.parseRequest(request); 总是会报错:Java. ...

  9. Java (四)APACHE Commons IO 复制文件

    上一篇:Java (三)APACHE Commons IO 常规操作 例1:复制文件 1 import java.io.File; 2 import java.io.IOException; 3 4 ...

随机推荐

  1. UVA 227 周期串

    题意: 给一个字符串,寻找最短的循环节 如abcabcabcabc以3为周期,也按6和12为周期. 分析: 因为循环节肯定是相等的,所以枚举串长度的所有约数的循环节再判断是否相等即可. 我的方法是枚举 ...

  2. Quartz.Net 学习之路02 初探Quartz.Net

    第二讲:简单的实例,看看Quartz.Net强在哪里? 直接上代码,代码里有注释: using System; using Quartz; using Quartz.Impl; namespace L ...

  3. expdp,impdp,include,exclude

    The examples below are based on:- the demo schema SCOTT that is created with script: $ORACLE_HOME/rd ...

  4. 【进击后端】Ubuntu 命令行 安装nginx

    一.安装nginx apt-get install nginx 安装路径为:/etc/nginx/conf.d 二.配置nginx,在conf.d目录下新建test.conf 新建文件的命令是vi t ...

  5. Chains (链 )

    Indy 中的工作队列系统,调度器,和链引擎都被叫做链. 当使用链的时候,一个基于链的 IOHandler 存储工作项目到有关的工作队列中.在一个工作单元被完成以前,执行这个工作单元的纤程是无法做其它 ...

  6. Codeforces Round #247 (Div. 2) B

    B. Shower Line time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  7. 008 frame relay

    Router>en Router#config t Enter configuration commands, one per line.  End with CNTL/Z. Router(co ...

  8. System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生。其它信息:尝试读取或写入受保护的内存。这通常指示其它内存已损坏。

    错误背景: 操作系统:编程环境:VS2013.  语言:VB.net:  数据库:SQLserver2008 做数据库连接时.发生的错误: 错误提示为: 说明:用VB.net连接SQLServer数据 ...

  9. Tree Operations 打印出有向图中的环

    题目: You are given a binary tree with unique integer values on each node. However, the child pointers ...

  10. SQLite数据库基本操作

    SQLite 是一个开源的嵌入式关系数据库,实现自包容.零配置.支持事务的SQL数据库引擎. 其特点是高度便携.使用方便.结构紧凑.高效.可靠. 与其他数据库管理系统不同,SQLite 的安装和运行非 ...