アットウィキロゴ

koukou

package dai;
 
import tool.*;
import java.io.*;
public class pro {
 int datanumber;
    String[] data=new String[5000];
     String[][] point=new String[500][30];
   int number;
    public static void main(String[] args) {
        pro test=new pro();
    }
    pro(){
 
        readfile sub2=new readfile();
        sub2.makedata("b.txt","UTF-8");
        data=sub2.data;
        datanumber=sub2.datanumber;
        int s;
        String k="</tr>";
        String str="";
        for(s=1;s<datanumber+1;s++){
        str=str+data[s];
 
        }
        int sx;
        String[] m=str.split(k); 
        for(s=0;s<m.length;s++){
        String[] de=m[s].split("</td>");
        for(sx=0;sx<de.length;sx++){
        String d=clean_str(de[sx]);
        point[s][sx]=d;
        }
        }
 
 
        number=m.length;
 
        writexml("ten.csv");
 
 
 
 
    }
 
    void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
for(s=0;s<number+1;s++){   
for(sx=1;sx<25;sx++){ 
String j=""+point[s][sx];
if(j.equals("null"))j="";    
pw.print(j);  
pw.print(","); 
}
pw.println(point[s][25]); 
}
 
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
} 
 
 
     String clean_str(String str){
 
    int m;
  String strx=str;
  for(m=1;m<15;m++){
  strx=fresh(strx);
  }
 
  strx=strx.replace("&nbsp","");
  strx=strx.replace("&nbsp","");
  strx=strx.replace(";","");
  return strx;
 
}
 
String fresh(String str){
 
  int p1=str.indexOf("<");
  int p2=str.indexOf(">",p1);
  String sp="";
  if(p1>-1)sp=str.substring(p1,p2+1);
 
  String k=str.replace(sp,"");
  return k;
}
 
 
}
 
最終更新:2018年06月27日 05:58