1
我有一个JSON文件,它看起来像这样的具体顺序:从文件中读取到的字符
{
"id":25,
"type":0,
"date":"Aug 28, 2017 12:14:28 PM",
"isOpen":true,
"message":"test"
}
/*
some lines here, comment, not json
*/
什么,我想要做的是能够从文件中读取,直到它检测到的开始评论部分“/ *”。
我能写一些代码,但输出似乎并没有因为某些原因被确定:
BufferedReader br = null;
FileReader fr = null;
String comm = "/*";
fr=new FileReader(FILENAME);
br=new BufferedReader(fr);
String currentLine;
while((currentLine=br.readLine())!=null&&!(currentLine=br.readLine()).equals(comm))
{
System.out.println(sCurrentLine);
}
br.close();
输出只给我:
"id": 25,
"date": "Aug 28, 2017 12:14:28 PM",
我没有json部分的开始{
也没有整个json消息"isOpen"
,"message"
...
我该如何读取并将结果存储为直到评论部分?
在这里你去。我编辑了我的答案,以使用stringbuilder(用于性能),告诉我如果你不能使用它,我会恢复它。 – Nathan