问题描述
我正在开发一个集成测试应用程序,这就是我在测试用例中所做的,我读取存储在 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 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)