我正在开发一个集成测试应用程序,这就是我在测试用例中所做的,我读取存储在 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模板网!
解析 ISO 8601 字符串本地日期时间,就像在 UTC 中Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期时间,就像在 UTC 中一样)
如何将公历字符串转换为公历?How to convert Gregorian string to Gregorian Calendar?(如何将公历字符串转换为公历?)
Java:GregorianCalendar 的最大值和最小值是什么/在哪Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
1582 年 10 月 15 日之前日期的日历到日期转换.公历Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日历到日期转换
java日历setFirstDayOfWeek不起作用java Calendar setFirstDayOfWeek not working(java日历setFirstDayOfWeek不起作用)
Java:获取当前星期几的值Java: getting current Day of the Week value(Java:获取当前星期几的值)