开发者

How to avoid Carriage Return Line feed pair

I am pulling debug Traces(in binary form) from Android phone using following command :

adb logcat -B > input.bin

Then I am feeding this binary data(input.bin) to a python script which parses it.

The problem I am facing is that in input.bin :

0A(line feed) is being replaced by 0D0A(CR and LF) , when above command is issued in Linux shell.

0A(line feed) is being replaced by 0D0D0A , when above command is issued in windows command prompt.

I don't want this behavior.

I tried to change the settings of my terminal by c开发者_运维百科hanging onlcr to -onlcr but no luck.

Who is doing these changes??? How to avoid them????


The problem is Linux uses only LF for line feed(\r) while the windows uses (\r\n) for new line as both line feed and carriage return. This is default behaviour at command prompt so I think you should work a little more complex but generic way and that is use Java program to fetch the output from this command and write the data to file through a Writer class not the Output Stream.

Process exec = Runtime.getRuntime().exec("adb logcat -B");

BufferedWriter buffWriter = new BufferedWriter(new FileWriter("FileName"));

BufferedReader buffReader = new BufferedReader(new InputStreamReader(exec.getInputStream()));

buffWriter.write(buffReader.readLine());

Now the output file is same for both OS.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜