Java默认换行符是’\n’。但有时数据并不以’\n’进行换行,办法如下:
public static void testRead(String confPath) throws IOException {
System.setProperty("line.separator", "\03");
BufferedReader brConf = new BufferedReader(new InputStreamReader(
new FileInputStream(confPath), "UTF-8"));
for (String line = brConf.readLine(); line != null; line = brConf.readLine()) {
System.out.println(line);
System.out.println("----------------");
}
brConf.close();
}
除’\03’外,业务还可能指定’\01’换行。具体使用什么看具体业务。