查找'abcd'是第几行,第几列

发布时间:2014-10-25 2:24:11
来源:分享查询网

public class Test { /** * @param args */ public static void main(String[] args) throws Exception { // TODO Auto-generated method stub BufferedReader reader=new BufferedReader(new FileReader("F://workbench//TestStruts//src//test//aa.txt")); String curLine; int lineIndex=1; while((curLine=reader.readLine())!=null){ int colIndex=curLine.indexOf("abcd"); if (colIndex>=0){ System.out.println(lineIndex+","+colIndex+":"+curLine); } lineIndex++; } } }

返回顶部
查看电脑版