有关java文本搜索问题 本帖最后由 flymaxdragon 于 2010-08-08 12:52:25 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.io.*;public class Read{ public static void main(String[] args) { try{ readText(); }catch(Exception e){} } public static void readText() throws Exception { //读取源文本文件 String read=""; BufferedReader sb=null; try{ sb=new BufferedReader(new FileReader("source.txt")); boolean start=false; while(true){ String temp=sb.readLine(); if(temp.indexOf("class_5")!=-1){ start=true; }else if(temp.startsWith(")")){ start=false; } if(start){ read+=temp+"\r\n"; } } }catch(Exception e){} //将读取的字符串写进dest.txt文本文件中 BufferedWriter bw=new BufferedWriter(new FileWriter("dest.txt")); bw.write(read); bw.write(")"); sb.close(); bw.close(); }} java Lexical Structure 中的literal翻译成中文是什么? 正则表达式问题 关于JFrame显示内容问题 关于对main函数理解上的问题 如何设置Frame的页边距? 什么都不会。怎么学java啊 谁用java开发socket通讯程序?100分相赠: 怎样去掉乱码? copy文件时候的一个小问题, 如何用JAVA程序取得UNIX机器下的当前用户? 聊天室问题 fckeditor怎样上传图片?
import java.io.*;
public class Read
{
public static void main(String[] args) {
try{
readText();
}catch(Exception e){}
}
public static void readText() throws Exception {
//读取源文本文件
String read="";
BufferedReader sb=null;
try{
sb=new BufferedReader(new FileReader("source.txt"));
boolean start=false;
while(true){
String temp=sb.readLine();
if(temp.indexOf("class_5")!=-1){
start=true;
}else if(temp.startsWith(")")){
start=false;
} if(start){
read+=temp+"\r\n";
}
}
}catch(Exception e){}
//将读取的字符串写进dest.txt文本文件中
BufferedWriter bw=new BufferedWriter(new FileWriter("dest.txt"));
bw.write(read);
bw.write(")");
sb.close();
bw.close();
}
}