アットウィキロゴ

FGGDDGKL

import java.io.*;

class ren{

String str;  
String data[]=new String[5000];
String article[]=new String[5000];
String memo[]=new String[5000];
int s,sx,datanumber;
int[] x=new int[500];
int[] y=new int[500];
int xmlnumber,page;

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

ren(){

readfile();

for(s=1;s<datanumber+1;s++){
article[s]=data[s];
}

for(page=1;page<datanumber+1;page++){

xymaker(article[page]);

str="";
for(s=1;s<xmlnumber;s++){
if(x[s+1]>y[s]+1)str=str+article[page].substring(y[s]+1,x[s+1]);
}
str=str.replace(" ","");
memo[page]=str;

}

writefile();

}

void writefile(){

try{
PrintWriter pw = new PrintWriter
(new BufferedWriter(new FileWriter("memo.txt")));

for(page=1;page<datanumber+1;page++){                                              
pw.println(memo[page]);                                                                
}

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

}




void xymaker(String str){
int p1;
int s;
s=1;
p1=str.indexOf("<");
x[1]=p1;
while(p1>-1){
p1=str.indexOf("<",p1+1);
if(p1>-1)s=s+1;
if(p1>-1)x[s]=p1;
}
xmlnumber=s;
for(s=1;s<xmlnumber+1;s++){
y[s]=str.indexOf(">",x[s]);
}

}




void readfile(){

String str;
int s,h;

s=0;
try{
BufferedReader br =new BufferedReader(new FileReader("article.txt"));
h=0;
while(h<50) {        
str = br.readLine();
if(str==null)h=100;
if(h<50)s=s+1;
if(h<50)data[s]=str;
}
br.close();
}
catch(IOException e){ System.out.println("入出力エラーです。");}
datanumber=s;
}

}
最終更新:2011年07月14日 11:12