import java.io.*;
class article{
String file;
String[] data=new String[1000];
String[] article=new String[1000];
int page,n,s;
int datanumber,articlenumber;
void makedata(){
page=0;
for(n=1;n<35;n++){
file="data/";
file=file+n;
file=file+".txt";
readfile(file);
makearticle();
}
articlenumber=page;
}
void makearticle(){
String str1,str2,str3;
int s,sx,s1,s2,s3;
int[] index=new int[100];
String bun;
str1="右メインここから";
str2="右メインここまで";
s1=0;
s2=0;
for(s=1;s<datanumber+1;s++){
if(data[s].indexOf(str1)>0)s1=s;
if(data[s].indexOf(str2)>0)s2=s;
}
str3="<a name=";
sx=0;
for(s=s1;s<s2;s++){
if(data[s].indexOf(str3)>-1)sx=sx+1;
if(data[s].indexOf(str3)>-1)index[sx]=s;
}
articlenumber=sx;
for(s=1;s<articlenumber;s++){
bun="";
for(sx=index[s];sx<index[s+1];sx++){
bun=bun+data[sx];
}
page=page+1;
article[page]=bun;
}
s=articlenumber;
bun="";
s3=0;
for(sx=index[s];sx<s2;sx++){
if(data[sx].indexOf("</table>")>-1)s3=sx;;
}
for(sx=index[s];sx<s3;sx++){
bun=bun+data[sx];
}
page=page+1;
article[page]=bun;
}
void readfile(String file){
String str;
BufferedReader br;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
}
最終更新:2011年07月16日 15:26