java txt 查找_JAVA 查找TXT文件内容

以下是代码:publicstaticvoidmain(String[]args){intdb2Name;Stringfname="c:\\1.txt";Filef=newFile(fname);try{FileReaderfr=newFileReader(f);BufferedReaderbr=newBufferedReade...

以下是代码:

public static void main (String[] args) {

int db2Name;

String fname = "c:\\1.txt";

File f = new File(fname);

try {

FileReader fr = new FileReader(f);

BufferedReader br = new BufferedReader(fr);

String s = br.readLine();

Pattern p = Pattern.compile("\\W(s.([0-9])*?)\\W");

Matcher m = p.matcher(s);

System.out.println("b");

while (s!=null){

while (m.find()) {

System.out.println(m.group(1).substring(1, 8));

db2Name=Integer.parseInt(m.group(1).substring(1, 8));

}s= br.readLine();

}

br.close();// 关闭缓冲读入流及文件读入流的连接.

System.out.println("a");

} catch (FileNotFoundException e1) {

System.err.println("File not found: " + fname);

} catch (IOException e2) {

e2.printStackTrace();

}

}

在1.TXT中

数据库 sacl1 的数据库配置 数据库配置发行版级别 = 0x0a00 数据库

发行版级别 = 0x0a00 数据库地域

这样就可以读取s开头的字母了。

在2.TXT中

数据库 sacl1 的数据库配置

数据库配置发行版级别 = 0x0a00

数据库发行版级别 = 0x0a00

数据库地域 = CN

数据库代码页 = 1386

这样就找不到S开头的字符了这个是为什么啊?

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值