アットウィキロゴ

ファイル fsf

import java.io.*;

class author{

String file,x1;
String[] data=new String[5000];
String[] person=new String[5000];
int page,datanumber;
int s,sx,p1,dlong;
int t;

public static void main(String [] args) {
        author test=new author();
            }

author(){

for(page=3000;page<4000;page++){

file="person/";
file=file+page;
file=file+".txt";

readfile(file);

for(s=1;s<datanumber+1;s++){
data[s]=data[s].replace(" ","△");
}


for(s=1;s<datanumber+1;s++){
data[s]=data[s].replace("委員長","△");
data[s]=data[s].replace("代理","△");
data[s]=data[s].replace("理事","△");
}

for(s=1;s<datanumber+1;s++){
p1=data[s].indexOf(")");
dlong=data[s].length();
if(p1>1)data[s]=data[s].substring(p1+1,dlong);
}

sx=0;
for(s=1;s<datanumber+1;s++){
p1=data[s].indexOf("君△");
if(p1<0)sx=sx+1;
if(p1<0)person[sx]=data[s];
}

for(s=1;s<datanumber+1;s++){
p1=data[s].indexOf("君△");
String[] x=data[s].split("君△");
if(p1>1)sx=sx+1;
if(p1>1)person[sx]=x[0];
if(p1>1)sx=sx+1;
if(p1>1)person[sx]=x[1];
}

for(s=1;s<sx+1;s++){
dlong=person[s].length();
x1=person[s].substring(dlong-1,dlong);
if(x1.equals("君"))person[s]=person[s].substring(0,dlong-1);
}


for(s=1;s<sx+1;s++){
dlong=person[s].length();
if(dlong>10)person[s]=person[s].substring(dlong-6,dlong);
person[s]=person[s].replace("△","");
}

file="author/";
file=file+page;
file=file+".txt";

writefile(file);

}

}

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;


}

void writefile(String file){

try{

PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));

for(s=1;s<sx+1;s++){                                                
pw.println(person[s]);                                                              
}

System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }

}





}
最終更新:2011年06月29日 15:28