0
所以我有這樣如何閱讀客戶提供的日誌文件?
blah blah blah blah blah blah blah
blah blah blah blah blah blah blah
<someTag>someDetail</someTag>
blah blah blah blah blah blah blah
blah blah blah blah blah blah blah
<someTag>someDetail</someTag>
blah blah blah blah blah blah blah
blah blah blah blah blah blah blah
這裏的日誌文件是我的代碼讀取該文件
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class DummyReadFile {
public static void main(String[] args) {
BufferedReader br = null;
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("C:/Hussi/logFile.log"));
while ((sCurrentLine = br.readLine()) != null) {
//System.out.println(sCurrentLine);
if(sCurrentLine.contains("<"))
{
System.out.println("==>>>"+sCurrentLine);
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
,但在我的輸出我得到
b l a h b l a h b l a h
< s o m e T a g >s o m e D e t a i l </s o m e T a g >
b l a h b l a h b l a h
< s o m e T a g >s o m e D e t a i l </s o m e T a g >
b l a h b l a h b l a h
< s o m e T a g >s o m e D e t a i l </s o m e T a g >
之間的空間字符實際上是一些方塊
我該怎麼做才能讀取f ile正確
我必須提及,文件格式,這樣的東西?
sCurrentLine.replaceAll(」」, 「」); –
如何使用XML解析器獲取標籤? – davejagoda