linux读取Windows的txt文件问题

问题:Windows下生成的txt文件,在Linux下读取时会读取到多余字符(如: ^M)

原因:Windows和Linux下的换行符不一致

解决:在Linux代码中将多余字符去掉

if(buf.find("\r") > 0)
  buf = buf.replace(buf.find("\r"), 1, "");

 

posted @ 2018-07-19 13:47  BlueOceans  阅读(541)  评论(0编辑  收藏  举报