文本文件中有10条数据,请编写程序读取第4行的信息
解决方案 »
- java 的 eclipse问题!
- win -7 有没有像 jre-6u12-windows-i586-p.exe的软件,安装后,不用配环境变量,直接可运行?
- jdialog超难问题,百度,google等没有找到答案,求高手进
- 关于无参构造方法结构。
- 请教各位老师一个取配置文件test.property的值的问题。。。
- java中将一个字符串中的某个子串替换为新串的函数是什么?
- 如何用JAVA实现在WEB中报表显示大量的数据?多谢
- 在JAVA中有枚举类型吗?
- 请问如何调用oracle函数?
- java List
- SWT中setenabled(false)在哪里把字体颜色设成灰色的
- 请教一个有关JAVA连接数据库后取值的问题(付代码)
BufferedReader in = new BufferedReader(new FileReader("F:\\my.txt"));
String str;
int row = 0;
while ((str = in.readLine()) != null) {
row ++;
if(row == 4){
System.out.println(str);// 这里是第四行
}
}
in.close();
} catch (IOException e) {
}
BufferedReader in = new BufferedReader(new FileReader(filePath));
String str = null;
int count = 0;
while ((str = in.readLine()) != null) {
count++;
if(count == lineNum){
break;
}
}
in.close();
return str;
}