使用java查找文本文件中单词的行号 [英] Finding line number of a word in a text file using java
本文介绍了使用java查找文本文件中单词的行号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在文本文件中搜索单词并使用java显示行号。如果它不止一次出现,我需要在输出中显示所有行号。有人可以帮我吗?
I require searching a word in a text file and display the line number using java. If it appears more than once I need to show all the line numbers in the output. Can anyone help me please?
推荐答案
使用Java类读取文本文件 LineNumberReader
并调用方法 getLineNumber
查找当前行号。
Read the text file using Java class LineNumberReader
and call method getLineNumber
to find the current line number.
http://docs.oracle.com/javase/7/docs/api/java/io /LineNumberReader.html
这篇关于使用java查找文本文件中单词的行号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文