行结束问题DOS> Linux>爪哇 [英] Line ending issue DOS > Linux > Java

查看:106
本文介绍了行结束问题DOS> Linux>爪哇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对160.000行文件有点麻烦,该文件是通过xlsx文件导出生成的,扩展名为.txt,但我担心它已被导出为类似DOS的格式文件,在每一行的末尾都有DOS换行符. 我正在使用用Java编写的解析器,在Ubuntu环境上运行,当我运行解析器时(由于其无法访问源代码的jar的一部分,我无法进行编辑),我得到了它,我得到NumberFormatException其中预期会有一个数字,我的行会这样结束:

I'm having a bit of a trouble with a 160.000 lines file, this file was generated through an export from an xlsx file, it has a .txt extension but i'm afraid that it has been exported as DOS-like file, at the end of each line it has the DOS line break. I'm using a parser written in java, running on an Ubuntu environment, and i'm getting this when i run the parser (which i cannot edit because its part of a jar i cant access the source code), i get NumberFormatException where a number is expected, my line ends like this:

4449

但是解析器将其视为

For input string: "4449&#xd;"<

您对此有解决方案吗?再次我自己无法访问解析器,我将不得不在我的Ubuntu机器上"编辑文件并删除这些行尾.

Do you have a solution for this? again i cant access the parser myself, i will have to edit the file "on my Ubuntu machine" and remove those line ends.

推荐答案

尝试对该文件使用dos2unix命令.那应该修复行终止符.

Try using the dos2unix command on that file. That should fix the line terminators.

> dos2unix winfile.txt unixfile.txt

参考:
dos2unix手册页

这篇关于行结束问题DOS&gt; Linux&gt;爪哇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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