package api;
import tool.*;
import java.io.*;
public class pro {
int s,datanumber;
String[] data=new String[50000];
String[] id=new String[5000];
String[] name=new String[5000];
String[] tab=new String[5000];
int number;
public static void main(String[] args) {
pro t=new pro();
}
pro(){
String code="00200531";
String urlx="http://api.e-stat.go.jp/rest/2.1/app/getStatsList?appId=aeec3b02995623cad42b80c80f73d176b7c77970";
urlx=urlx+"&statsCode="+code;
getdata sub=new getdata();
sub.makedata(urlx,"UTF-8");
data=sub.data;
datanumber=sub.datanumber;
String str="";
for(s=1;s<datanumber+1;s++){
str=str+data[s];
}
String[] x=str.split("</TABLE_INF>");
String[] de=new String[5000];
int sx=0;
for(s=1;s<x.length;s++){
if(x[s].indexOf("<TABLE_INF")>-1)sx=sx+1;
if(x[s].indexOf("<TABLE_INF")>-1)de[sx]=x[s];;
}
number=sx;
for(s=1;s<number+1;s++){
int p1=de[s].indexOf("<TABLE_INF");
int p2=de[s].indexOf(">",p1+1);
id[s]=de[s].substring(p1,p2);
id[s]=id[s].replace("<TABLE_INF id=","");
id[s]=id[s].replace("\"","");
System.out.println(id[s]);
p1=de[s].indexOf("<STATISTICS_NAME>");
p2=de[s].indexOf("</STATISTICS_NAME>",p1+1);
name[s]=de[s].substring(p1,p2);
name[s]=name[s].replace("<STATISTICS_NAME>","");
System.out.println(name[s]);
p1=de[s].indexOf("<TITLE");
p1=de[s].indexOf(">",p1);
p2=de[s].indexOf("</TITLE>",p1+1);
tab[s]="";
if(p1>-1)tab[s]=de[s].substring(p1+1,p2);
tab[s]=tab[s].replace("<TITLE>","");
System.out.println(tab[s]);
}
writexml("ren.txt");
}
void writexml(String file){
int s,sx;
try{
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file)));
pw.println("n,t,c");
for(s=1;s<number+1;s++){
pw.print(name[s]);
pw.print(",");
pw.print(tab[s]);
pw.print(",");
pw.println(id[s]);
}
System.out.println("ファイルに書きこみました。");
pw.close();
} catch(IOException ep){ System.out.println("入出力エラーです。"); }
}
}
最終更新:2017年03月03日 02:34