我有一些代码可以从文件中读取行,我想识别行何时开始或fisrt字符(非空白)为’ *‘并忽略它,因此在while语句中添加如下内容
*
if(line[0]=='*') ignore that line
我有类似的东西:
input = new BufferedReader(new FileReader(new File(finaName))); String line = null; while ((line = input.readLine()) != null) { String[] words = line.split(" "); .... }
如何完成代码?
input = new BufferedReader(new FileReader(new File(finaName))); String line = null; while ((line = input.readLine()) != null) { if(line.trim().indexOf('*') == 0) continue; String[] words = line.split(" "); .... }