Carriage Return and Line Feed windows and Linux java application(回车和换行窗口和 Linux java 应用程序)
问题描述
我正在开发一个集成测试应用程序,这就是我在测试用例中所做的,我读取存储在 cvs 中的测试输入文件,将其写入文件系统中的文件,应用程序轮询文件的目录,处理它并创建输出文件,然后轮询输出文件的目录,如果两个文件内容相等,则测试用例成功(我正在将输入文件和输出文件读入字符串并进行比较).
I am working on a integration test application, this is what I am doing in the test case, I read a test input file,which is stored in the cvs , write it to a file in the file system,the application polls the directory for the file, processes it and creates the output file, and I poll the directory for the output file, test case is successful if the both the file contents are equal(I am reading the both input files and output files into strings and comparing them).
问题是这个测试用例在 linux 系统中运行时失败,原因是存储在 cvs 中的文件是从包含 CRLF 作为行终止符的 Windows 系统签入的,而生成的输出文件具有行终止为 CR,现在当我读取这些文件并逐个字符比较它们时,它们不匹配.
The problem is this test case fails when its runs in a linux system, the reason being the file which is stored in the cvs was checked in from a windows system which contains CRLF as the line terminations whereas the output file generated has the line terminations as CR,now when I read these files and compare them character by character, they are having a mismatch.
有人可以帮忙吗?
推荐答案
您可以使用 System.getProperty("line.separator") 来检查主机操作系统的行分隔符
由于您使用的是文本文件,您还可以逐行比较文件内容.检查 LineNumberReader.readLine()
.
Since you're using text files, you can also compare the file contents line by line. Check LineNumberReader.readLine()
for that.
这篇关于回车和换行窗口和 Linux java 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:回车和换行窗口和 Linux java 应用程序


基础教程推荐
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01