アットウィキロゴ

umxzz

package uma;
 
 
import java.io.*;
public class pro {
 
      int s,datanumber;
    String[] data=new String[60000];
    int number;
     String[] name=new String[600];
    String[] namex=new String[600];
      String[] namey=new String[600];
     String[] pop=new String[600];
       String[] point=new String[600];
        String[] time=new String[600];
          String[] sex=new String[600];
          String[] w=new String[600];
 
    public static void main(String[] args) {
        pro y=new pro();
    }
 
    pro(){
 
        int tr;
        for(tr=1;tr<1247;tr++){
 
    readx("gdata/"+tr+".txt");    
 
 
    int s1=0;
    for(s=1;s<datanumber+1;s++){
   int h1=0;
    if(data[s].indexOf("着順")>-1)s1=s;  
    }
 
     int s2=0;
    for(s=s1+2;s<datanumber+1;s++){
   int h=0;
 if(data[s].indexOf("</table>")>-1)h=h+1;
 if(s2==0)h=h+1;
 if(h==2)s2=s; 
    }
 
 
 
 
    String str="";
     for(s=s1+1;s<s2;s++){
 str=str+data[s];
       }
 
 
 
     String[] x=str.split("</tr>");
     int sx;
     for(s=1;s<x.length;s++){
     String[] y=x[s].split("</td>");
     for(sx=0;sx<y.length;sx++){ 
     if(sx==13)namey[s]=change(y[sx]);
     if(sx==4)name[s]=change(y[sx]);
      if(sx==5)sex[s]=change(y[sx]);
     if(sx==8)namex[s]=change(y[sx]);    
     if(sx==0)point[s]=change(y[sx]);   
     if(sx==14)pop[s]=change(y[sx]);
     if(sx==3)time[s]=change(y[sx]);
      if(sx==7)w[s]=change(y[sx]);
     }
     }
 
 
    number=x.length-1;
 
    writexml("uma2/"+tr+".txt");
        }
 
 
 
 
    }
 
 
      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("<point>"); 
pw.print(point[s]); 
pw.print("</point>");
pw.print("<pop>"); 
pw.print(pop[s]); 
pw.print("</pop>");
pw.print("<sex>"); 
pw.print(sex[s]); 
pw.print("</sex>");
pw.print("<w>"); 
pw.print(w[s]); 
pw.print("</w>");
pw.print("<name>"); 
pw.print(name[s]); 
pw.print("</name>"); 
pw.print("<time>"); 
pw.print(time[s]); 
pw.print("</time>"); 
pw.print("<jokey>"); 
pw.print(namex[s]); 
pw.print("</jokey>"); 
pw.print("<man>");
pw.print(namey[s]);
pw.println("</man>"); 
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
    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;
 
} 
 
   String change(String str){
 
        int n;
        for(n=1;n<11;n++){
        str=rev(str);    
        }
 
        str=str.replace(" ","");
 
        return str;
    }
 
 String rev(String str){
 
        if(str==null)str="";
 
        int p1=str.indexOf("<");
        int p2=-1;
        if(p1>-1)p2=str.indexOf(">",p1);
        String strx="";
        if(p2>-1)strx=str.substring(p1,p2+1);
        str=str.replace(strx,"");
 
        return str;
    }    
 
 
}
 
最終更新:2016年05月07日 14:07