import java.io.*;
class pro{
String data;
String str,file;
int n,nx,p1,p2,sx;
int xx[]=new int[1000];
int yy[]=new int[1000];
String[] credit=new String[1000];
String[] word=new String[1000];
int xmlnumber,wordnumber;
int t,h;
public static void main(String args[]){
pro test=new pro();
}
pro(){
file="data/1410.txt";
readfile(file);
makexml(data);
for (n=1;n<xmlnumber;n++){
credit[n]=makecredit(n);
word[n]=makeword(n);
}
System.out.println(xmlnumber);
writefile("ren.txt");
}
String makeword(int n){
int p1,p2;
String str;
p1=yy[n]+1;
p2=xx[n+1];
str=data.substring(p1,p2);
return str;
}
String makecredit(int n){
int p1,p2;
String str;
p1=xx[n]+1;
p2=yy[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);
xx[1]=p1;
yy[1]=p2;
s=0;
while(p1>0){
s=s+1;
p1=data.indexOf("(",p2);
p2=data.indexOf(")",p1);
xx[s]=p1;
yy[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月11日 12:48