アットウィキロゴ

ggglp

import java.io.*;

class pro{

String data;
String str,file;
int n,nx,p1,p2,sx;
int x[]=new int[1000];
int y[]=new int[1000];
String[] credit=new String[1000];
String[] word=new String[1000];
int xmlnumber,wordnumber;
int t,h;
int m,m1,m2,m3,d;

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


pro(){


m=0;
for(m1=13;m1<20;m1++){
if(m1==13)m3=35;
if(m1==14)m3=42;
if(m1==15)m3=30;
if(m1==16)m3=35;
if(m1==17)m3=31;
if(m1==18)m3=31;
if(m1==19)m3=10;
for(m2=1;m2<m3+1;m2++){

file="data/";
d=100*m1+m2;
file=file+d;
file=file+".txt";

readfile(file);

makexml(data);

for (n=1;n<xmlnumber;n++){
credit[n]=makecredit(n);
word[n]=makeword(n);
}

System.out.println(xmlnumber);

m=m+1;
file="fdata/";
file=file+m;
file=file+".txt";

writefile(file);

}
}

}

String makeword(int n){
int p1,p2;
String str;

p1=y[n]+1;
p2=x[n+1];

str=data.substring(p1,p2);

return str;
}

String makecredit(int n){
int p1,p2;
String str;

p1=x[n]+1;
p2=y[n];

str=data.substring(p1,p2);

return str;
}


void writefile(String file){

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

for(n=1;n<xmlnumber-1;n++){
pw.print(n);  
pw.print(",");  
pw.print(credit[n]);    
pw.print(",");  
pw.println(word[n]);    

}

System.out.println("ファイルに書きこみました。");

pw.close();
}
catch(IOException ep){ System.out.println("入出力エラーです。"); }



}




void makexml(String data){
int s,p1,p2;

p1=data.indexOf("(");
p2=data.indexOf(")",p1);
x[1]=p1;
y[1]=p2;
s=0;
while(p1>0){
s=s+1;
p1=data.indexOf("(",p2);
p2=data.indexOf(")",p1);
x[s]=p1;
y[s]=p2;
}

xmlnumber=s-1;

}


void readfile(String file){

String s;
BufferedReader br;

data="";

try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"SJIS"));  
while((s = br.readLine()) != null) {  
data=data+s;  
}
br.close();
} catch (IOException e) {System.out.println(e);}


}

}
最終更新:2011年05月15日 04:55