参考链接: Java 字符串方法
private static void readLine(String content) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(content.getBytes(Charset.forName("utf8"))), Charset.forName("utf8")));
String line;
StringBuffer strbuf = new StringBuffer();
while ((line = br.readLine()) != null) {
if (!line.trim().equals("")) {
line = "line" line;//每行数据
strbuf.append(line "rn");
}
}
System.out.println(strbuf.toString());
}
}
执行结果
linexxxxx
linexxxxx
linexxxxx