package don;
import tool.*;
import java.io.*;
public class pro {
int s,datanumber;
String[] data=new String[5000];
String[] name=new String[5000];
String[] school=new String[5000];
String[] age=new String[5000];
String[] bat=new String[5000];
String[] high=new String[5000];
String[] weight=new String[5000];
String[] year=new String[5000];
int number;
String[] web=new String[5000];
public static void main(String[] args) {
pro test=new pro();
}
pro(){
readx("tigers.txt");
for(s=1;s<datanumber+1;s++){
catchword sub2=new catchword();
String str=sub2.makedata(data[s],"index");
int n=numx(str);
str=sub2.makedata(data[s],"credit");
if(str.indexOf("名")>-1)name[n]=sub2.makedata(data[s],"point");
if(str.indexOf("校")>-1)school[n]=sub2.makedata(data[s],"point");
if(str.indexOf("齢")>-1)age[n]=sub2.makedata(data[s],"point");
if(str.indexOf("長")>-1)high[n]=sub2.makedata(data[s],"point");
if(str.indexOf("重")>-1)weight[n]=sub2.makedata(data[s],"point");
if(str.indexOf("数")>-1)year[n]=sub2.makedata(data[s],"point");
if(str.indexOf("投")>-1)bat[n]=sub2.makedata(data[s],"point");
number=n;
}
for(s=1;s<number+1;s++){
weight[s]=rev(weight[s]);
high[s]=rev(high[s]);
bat[s]=rev(bat[s]);
age[s]=rev(age[s]);
year[s]=rev(year[s]);
school[s]=rev(school[s]);
}
int p1,p2;
for(s=1;s<number+1;s++){
p1=name[s].indexOf("baseball");
p2=name[s].indexOf("\"",p1);
web[s]="";
if(p1>-1)web[s]=name[s].substring(p1,p2);
}
for(s=1;s<number+1;s++){
p1=name[s].indexOf("baseball");
p1=name[s].indexOf(">",p1);
p2=name[s].indexOf("<",p1);
if(p1>0)name[s]=name[s].substring(p1+1,p2);
}
writexml("ren.txt");
}
String rev(String str){
int p1;
String strx=str;
p1=strx.indexOf("<td>");
if(p1>-1)strx=strx.substring(p1+4,strx.length());
return strx;
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
for(s=1;s<number+1;s++){
pw.print("<name>");
pw.print(name[s]);
pw.print("</name>");
pw.print("<link>");
pw.print(web[s]);
pw.print("</link>");
pw.print("<year>");
pw.print(year[s]);
pw.print("</year>");
pw.print("<age>");
pw.print(age[s]);
pw.print("</age>");
pw.print("<school>");
pw.print(school[s]);
pw.print("</school>");
pw.print("<weight>");
pw.print(weight[s]);
pw.print("</weight>");
pw.print("<high>");
pw.print(high[s]);
pw.print("</high>");
pw.print("<bat>");
pw.print(bat[s]);
pw.println("</bat>");
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
int numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
void readx(String file){
String str;
BufferedReader br;
int s;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));
while((str = br.readLine()) != null) {
s=s+1;
data[s]=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}
datanumber=s;
}
}
最終更新:2015年10月01日 08:40