Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
345 views
in Technique[技术] by (71.8m points)

java - How to convert files from Dos to Unix

I am having several files which I want to convert from Dos to Unix. Is there any API or method which will help me to do this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There are linux tools that can do this (dos2unix for example).

In Java it can be done with String.replaceAll().

DOS uses for line termination, while UNIX uses a single .

String unixText = windowsText.replaceAll("
", "
"); // DOS2UNIX

So no, no API exists. Yes, it is dead easy.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...