import java.io.*;
public class article{
String[] data=new String[50000];
String[] author=new String[5000];
String[] article=new String[5000];
String[][] credit=new String[300][500];
int s,sx,sxs,datanumber,creditnumber;
int tx,n,articlenumber,authornumber;
String file;
String str,str1,str2;
int page,p1,p2,h;
public static void main(String[] args){
article test=new article();
}
article(){
readfile("author.txt");
authornumber=datanumber;
for(s=1;s<authornumber+1;s++){
author[s]=data[s];
}
for(page=1;page<220;page++){
file="author/";
file=file+page;
file=file+".txt";
readfile(file);
for(s=1;s<datanumber+1;s++){
credit[page][s]=data[s];
}
}
for(s=1;s<authornumber+1;s++){
tx=0;
for(page=1;page<220;page++){
file="nword/";
file=file+page;
file=file+".txt";
readfile(file);
for(sx=1;sx<datanumber+1;sx++){
if(author[s].equals(credit[page][sx]))tx=tx+1;
if(author[s].equals(credit[page][sx]))article[tx]=data[sx];
}
}
articlenumber=tx;
file="article/";
file=file+s;
file=file+".txt";
writefile(file);
}
}
void writefile(String file){
int tx;
try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter(file)));
for(tx=1;tx<articlenumber+1;tx++){
pw.println(article[tx]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
void readfile(String file){
String str;
BufferedReader br;
int s;
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月13日 09:57