java 解析文本文件 中换行问题
上图是在编辑器里面显示的要解析文件
此图是在编辑器里点击显示所有字符的结果
怎么用java删除LF
------解决方案--------------------
String result = "";
File file = new File("E:\\testtesttest\\test2.txt");
InputStream in = null;
byte[] tempByte = new byte[1024];
int byteread = 0;
try {
in = new FileInputStream(file);
while ((byteread = in.read(tempByte)) != -1 ) {
result += new String(tempByte, 0, byteread);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
result = result.replaceAll("\n", "");
try{
PrintWriter pw = new PrintWriter(new File("E:\\testtesttest\\test3.txt"));
pw.print(result);
pw.flush();
pw.close();
}catch(Exception e){
e.printStackTrace();
}
System.out.println("over");