アットウィキロゴ

deiii

package moci;
import tool.*;
import java.io.*;
 
public class pro {
  int s,datanumber;
String[] data=new String[5000];
String[] link=new String[5000];
    String date;
 
    public static void main(String[] args) {
        pro t=new pro();
    }
 
    pro(){
 
        int tr;
 
 
        for(tr=120;tr<358;tr++){
 
         readfile sub=new readfile();
   sub.makedata("data/"+tr+".txt","UTF-8");
   data=sub.data;
   datanumber=sub.datanumber;
 
   String str1="<!--記事ここから-->";
    String str2="<!--記事ここまで-->";
 
    int s1=0,s2=0;
 
   for(s=1;s<datanumber+1;s++){
  if(data[s].indexOf(str1)>-1)s1=s;
   if(data[s].indexOf(str2)>-1)s2=s;  
 
   }
 
   for(s=1;s<datanumber+1;s++){
  if(data[s].indexOf("<title>")>-1)date=data[s];
   }
 
   int p1=date.indexOf("今週の映画ランキング");
   date=date.substring(0,p1);
   date=date.replace("<title>","");
 
 
   String str="";
   for(s=s1+1;s<s2;s++){
    str=str+data[s];
 
    }
 
   String[] x=str.split("</dl>");
 
    for(s=0;s<x.length;s++){
   link[s+1]=x[s];
 
    }
 
    String str3="<span class=\"xs\">";
    for(s=1;s<11;s++){
    String[] y=link[s].split("</dt>");
link[s]=y[1].replace(str3,"△");    
    link[s]=change(link[s]);    
 
    }
 
 
 
 
   writexml("gdata/"+tr+".txt");
        }
 
 
 
    }
 
       void writeindex(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
     void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=1;s<11;s++){  
pw.println(date+"△"+s+"△"+link[s]); 
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
 
    String change(String str){
 
        int n;
        for(n=1;n<51;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年12月03日 13:37