求一段JAVA代码 给定一个字符串(不包括回车换行之类的特殊字符),给定一个文本文件(可能含有汉字),如果某一行中包含该字符串就算一次,打印出该文件中总共出现多少次。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用正则表达式可以搞定 String 里也带此类方法 import java.io.BufferedReader;import java.io.FileReader;public class FileRead { public static void main (String[] args) { String str = "桌面"; String filepath = "c:/debug.txt"; try { FileReader fr = new FileReader(filepath); BufferedReader in = new BufferedReader(fr); String inputLine; int n = 0; while ((inputLine = in.readLine()) != null) { if (inputLine.indexOf(str) != -1) { n++; } } System.out.println("n==============="+n); in.close(); } catch (Exception e) { System.out.println("error"); } }}debug.txt正在处理:C:\Documents and Settings\Administrator\桌面\酷我音乐盒 2009.lnk 正在处理:E:\tools\KWMUSIC\KwMusic.exe 正在处理:E:\tools\KWMUSIC\KwMusic.exe 正在处理:E:\tools\KWMUSIC\KwMusic.exe 正在处理:E:\tools\KWMUSIC\Encode.exe 正在处理:E:\tools\KWMUSIC\recoEngine.ex webservice WSDLException 谁能给个strut拦截器的实例,想研究研究。。。 JSP问题 问个幼稚的问题,大家开发的jsp文件都是放在src/web/jsp/这个目录下面的吗? 求助:jsp连接dbf数据库进行查询的问题 初级的调用存储过程的问题,在线等,50分 我想采集一个JAVAWEB网站的内容(有用户名和密码验证的,我有用户名和密码) java如何生成exe文件 我用prompt弹出一个对话框,是要输入密码的,请问如何实现文本框输入的是密码是以“*”显示的? 关于从数据库读出空值问题 肯能是没有配置数据源 lucene检索数据库问题
import java.io.BufferedReader;
import java.io.FileReader;public class FileRead {
public static void main (String[] args) {
String str = "桌面";
String filepath = "c:/debug.txt";
try {
FileReader fr = new FileReader(filepath);
BufferedReader in = new BufferedReader(fr);
String inputLine;
int n = 0;
while ((inputLine = in.readLine()) != null) {
if (inputLine.indexOf(str) != -1) {
n++;
}
}
System.out.println("n==============="+n);
in.close();
} catch (Exception e) {
System.out.println("error");
}
}
}
debug.txt正在处理:C:\Documents and Settings\Administrator\桌面\酷我音乐盒 2009.lnk
正在处理:E:\tools\KWMUSIC\KwMusic.exe
正在处理:E:\tools\KWMUSIC\KwMusic.exe
正在处理:E:\tools\KWMUSIC\KwMusic.exe
正在处理:E:\tools\KWMUSIC\Encode.exe
正在处理:E:\tools\KWMUSIC\recoEngine.ex