回车和换行窗口和Linux Java应用程序 [英] Carriage Return and Line Feed windows and Linux java application

查看:182
本文介绍了回车和换行窗口和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系统中运行时失败,原因是从Windows系统中检入了存储在cvs中的文件,该系统包含CRLF作为行终止,而生成的输出文件具有行终止,称为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.

任何人都可以在这里帮忙.

could anyone help here.

推荐答案

您可以使用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应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆