
已解决问题
谷歌火炎焱燚AYM用户在2017.10.24提交了关于“中国女排j**a查TXT文件内容”的提问,欢迎大家涌跃发表自己的观点。目前共有2个回答,最后更新于2025-02-14T16:52:11。packagereadbook;
importj**a.io.BufferedReader;
importj**a.io.File;
importj**a.io.FileNotFoundException;
importj**a.io.FileReader;
importj**a.io.IOException;
importj**a.util.Scanner;
importj**a.util.regex.Matcher;
importj**a.util.regex.Pattern;
publicclassbook{
publicstaticvoidmain(String[]args){
intdb2Name;
Stringfname="e:\\book.txt";
Filef=newFile(fname);
try{
FileReaderfr=newFileReader(f);
BufferedReaderbr=newBufferedReader(fr);
Strings=br.readLine();
while(s!=**ll){
int**m=s.indexOf("红楼梦");//获得s所在的下标,
//让后看你要的应该是s开始到di8个
if(**m!=-1){
Stringstr=**ll;
try{
str=s.substring(**m,**m+1024);
}catch(Exceptione){
str=s.substring(**m);
}
System.out.println(str);//这个就应该是你要的东西了
}
s=br.readLine();
}
br.close();//关闭缓冲读入流及文件读入流的连接.
System.out.println("查询结束!!!");
}catch(FileNotFoundExceptione1){
System.err.println("Filenotfound:"+fname);
}catch(IOExceptione2){
e2.printStackTrace();
}
}
privatestaticStringScanner(Scannerin){
//TODOAuto-generatedmethodstub
return**ll;
}
}
代码中的int**m=s.indexOf("红楼梦");里面的“红楼梦”我想要从键盘输入,应该怎么做
希望大家能够帮助她。详细问题描述及疑问:
packagereadbook;
importj**a.io.BufferedReader;
importj**a.io.File;
importj**a.io.FileNotFoundException;
importj**a.io.FileReader;
importj**a.io.IOException;
importj**a.util.Scanner;
importj**a.util.regex.Matcher;
importj**a.util.regex.Pattern;
publicclassbook{
publicstaticvoidmain(String[]args){
intdb2Name;
Stringfname="e:\\book.txt";
Filef=newFile(fname);
try{
FileReaderfr=newFileReader(f);
BufferedReaderbr=newBufferedReader(fr);
Strings=br.readLine();
while(s!=**ll){
int**m=s.indexOf("红楼梦");//获得s所在的下标,
//让后看你要的应该是s开始到di8个
if(**m!=-1){
Stringstr=**ll;
try{
str=s.substring(**m,**m+1024);
}catch(Exceptione){
str=s.substring(**m);
}
System.out.println(str);//这个就应该是你要的东西了
}
s=br.readLine();
}
br.close();//关闭缓冲读入流及文件读入流的连接.
System.out.println("查询结束!!!");
}catch(FileNotFoundExceptione1){
System.err.println("Filenotfound:"+fname);
}catch(IOExceptione2){
e2.printStackTrace();
}
}
privatestaticStringScanner(Scannerin){
//TODOAuto-generatedmethodstub
return**ll;
}
}
代码中的int**m=s.indexOf("红楼梦");里面的“红楼梦”我想要从键盘输入,应该怎么做
期待您的答案,感谢你,我会记得你对我的好的 !