我有一些代码来从文件中读取行,我想识别行何时开始或第一个字符(非空白)是 '*
' 并忽略它,所以在 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(" ");
....
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)