linux read file by line

Problem background

After returning to the Windows side by line-by-line reading on the linux side through java, you will find the problem of missing newline characters. The reason is that the Unix system newline character is \nand the Windows newline character is\r\n

Solution

import cn.hutool.core.io.FileUtil;

String content = FileUtil.readUtf8String(new File(filePath));

What you get is the text content

Guess you like

Origin blog.csdn.net/wenyichuan/article/details/110420224