解决方案 »
- java的内存到底分为几个区?有的说就是栈和堆,有的说还有代码段、常量区等?
- ? - URLConnection.getExpiration()是什么意思
- java swing
- JAVA怎样读取指定的行呢
- TOMCAT5.59安装成功后,http:\\localhost 为什么没有正确显示页面:
- 谁肯来这(http://community.csdn.net/Expert/topic/3123/3123671.xml?temp=.8257105)
- date.getTime的问题
- 高薪急聘JAVA,MQSI工程师
- sharetop(天生不笨)请进来拿分!!!
- 请问String str;String str="";String str=null 的区别
- 初学者请教一个多线程问题
- StringBuffer传的不是引用吗?
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;public class Demo6 {
public static void main(String[] args) throws FileNotFoundException {
String filePath = "E:/JAVA_WorkSpace/Thread/src/test.txt";
BufferedReader in = new BufferedReader(new FileReader(
new File(filePath)));
String msg = null;
// 记录行数
int line = 0;
// 指定要查询的行
int request = 3;
try {
while ((msg = in.readLine()) != null) {
line++;
if (line == request) {
int index = msg.indexOf("BN:");
System.out.println(msg.substring(index + "BN:".length()));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}