アットウィキロゴ

fatff

package kand;
 
import java.io.*;
 
public class pro {
 
    int s,datanumber;
    String[] data=new String[60000];
   String[] city=new String[60000];
    String[] code=new String[60000];
 String[] adr=new String[60000];
    String[][] point=new String[120][30000];
      String[] geo=new String[30000];
 
      int lastyear=29;
 
   public static void main(String[] args) {
        pro te=new pro();
    }
 
    pro(){
 
        readx("data.xml","administrativeAreaCode");
 
 
for(s=1;s<datanumber+1;s++){
   code[s]=change(data[s]);
    }
 
System.out.println(datanumber);
 
  readx("data.xml","cityName");
 
for(s=1;s<datanumber+1;s++){
   city[s]=change(data[s]);
    }
 
System.out.println(datanumber);
 
 readp("data.xml","acreage");
 
for(s=1;s<datanumber+1;s++){
   adr[s]=change(data[s]);
    }
 
System.out.println(datanumber);        
 
          int sx;      
  for(sx=58;sx<64;sx++){
      String w1="postedLandPriceOfS"+sx;  
      readx("data.xml",w1);
    for(s=1;s<datanumber+1;s++){
      point[sx+20][s]=data[s];
            }
            }              
 
 
 
 
  for(sx=1;sx<lastyear+1;sx++){
      String w1="postedLandPriceOfH"+sx;
      if(sx<10)w1="postedLandPriceOfH0"+sx;
      readx("data.xml",w1);
    for(s=1;s<datanumber+1;s++){
      point[sx+88][s]=data[s];
            }
            } 
 
 
   readx("data.xml","<gml:pos>");
 
   for(s=1;s<datanumber+1;s++){
   geo[s]=change(data[s]);
    }
 
   System.out.println(datanumber);
 
   writexml("ten.txt");
 
 
 
    }
 
    void writexml(String file){ 
 
    int s,sx;
 
try{ 
PrintWriter pw = new PrintWriter (new BufferedWriter(new FileWriter(file))); 
 
int yy=lastyear+88;
 
for(s=1;s<datanumber+1;s++){   
pw.print("<city>"); 
pw.print(city[s]); 
pw.print("</city>"); 
pw.print("<code>"); 
pw.print(code[s]); 
pw.print("</code>");
pw.print("<adr>"); 
pw.print(adr[2*s]); 
pw.print("</adr>");
for(sx=83;sx<yy+1;sx++){ 
pw.print("<"); 
pw.print(sx+1900); 
pw.print(">");  
pw.print(change(point[sx][s])); 
pw.print("</"); 
pw.print(sx+1900); 
pw.print(">");  
}
pw.print("<geo>"); 
pw.print(geo[s]); 
pw.println("</geo>");
}
 
System.out.println("ファイルに書きこみました。"); 
pw.close(); 
} catch(IOException ep){ System.out.println("入出力エラーです。"); } 
 
 
}
 
 
    String change(String str){
 
        int n;
        for(n=1;n<5;n++){
        str=rev(str);    
        }
 
        str=str.replace(" ","");
 
        return str;
    }
 
 String rev(String str){
 
        if(str==null)str="";
 
        int p1=str.indexOf("<");
        int p2=str.indexOf(">",p1);
        String strx="";
        if(p2>-1)strx=str.substring(p1,p2+1);
        str=str.replace(strx,"");
 
        return str;
    }    
 
 
 
     void readx(String file,String word){
 
String str;
BufferedReader br;  
int s;
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));  
while((str = br.readLine()) != null) {  
if(str.indexOf(word)>-1)s=s+1;
if(str.indexOf(word)>-1)data[s]=str;  
}
br.close();
} catch (IOException e) {System.out.println(e);}  
 
datanumber=s;
 
} 
 
     void readp(String file,String word){
 
String str;
BufferedReader br;  
int s;
String strp="";
s=0;
try {
br = new BufferedReader(new InputStreamReader(new FileInputStream(file),"UTF-8"));  
while((str = br.readLine()) != null) {  
if(str.indexOf(word)>-1)s=s+1;
if(str.indexOf(word)>-1)data[s]=strp;  
strp=str;
}
br.close();
} catch (IOException e) {System.out.println(e);}  
 
datanumber=s;
 
} 
}
最終更新:2017年04月24日 06:20