📄 outputtoarray.java
字号:
package net.aetherial.gis.our.duibi.readXLS;
import java.io.File;
import net.aetherial.gis.surface.CreateFile;
import net.aetherial.gis.our.duibi.data.RoadGLJ;
import java.util.Vector;
import net.aetherial.gis.our.duibi.data.AllRoad;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class OutPutToArray {
private Vector mycontaint = new Vector();
public OutPutToArray() {
}
private void addData(){
(new ReadXiandao()).addXianDao();
new ReadXiangDao().addXianDao();
}
public void createFile(String message,String file){
CreateFile cf = new CreateFile(new File(file));
cf.setEncode("GB2312");
cf.memoryToFile(message);
}
private void findOne(RoadGLJ[] temp){
if (temp != null) {
double licheng = 0.0;
// System.out.print(temp[0].getShi() + "\t" + temp[0].getXian());
for (int i = 0; i < temp.length; i++) {
if ((temp[i].getShi().equals(temp[0].getShi()))&&(temp[i].getXian().equals(temp[0].getXian()))) {
licheng = licheng + temp[i].getLicheng();
this.mycontaint.addElement(temp[i]);
temp[i].setFind(true);
}
}
// System.out.print("\t" + licheng +"\r\n");
AllRoad.removeFinded();
}
}
private void findShi(RoadGLJ[] temp){
if (temp != null) {
double licheng = 0.0;
System.out.print(temp[0].getShi());
for (int i = 0; i < temp.length; i++) {
if (temp[i].getShi().equals(temp[0].getShi())) {
licheng = licheng + temp[i].getLicheng();
// this.mycontaint.addElement(temp[i]);
temp[i].setFind(true);
}
}
System.out.print("\t" + licheng +"\r\n");
AllRoad.removeFinded();
}
}
public void run(){
RoadGLJ[] temp = null;
while(true){
temp = AllRoad.getGljData();
if ((temp == null) || (temp.length == 0)) {
break;
}else{
findOne(temp);
}
}
}
public void runShi(){
RoadGLJ[] temp = null;
while(true){
temp = AllRoad.getGljData();
if ((temp == null) || (temp.length == 0)) {
break;
}else{
findShi(temp);
}
}
}
private void setData(){
AllRoad.removeAll();
for (int i = 0; i < mycontaint.size(); i++) {
AllRoad.add((RoadGLJ)mycontaint.elementAt(i));
}
}
public String printQu(String shi,String xian){
String n = "";
RoadGLJ[] temp = AllRoad.getGljData(shi,xian);
if (temp != null) {
for (int i = 0; i < temp.length; i++) {
n = n + temp[i].getShi() + "\t" + temp[i].getXian() + "\t" + temp[i].getRoadNumber() + "\t" + temp[i].getLicheng() + "\r\n";
}
}
return n;
}
public String printMycontaint(){
String n= "";
RoadGLJ temp = null;
for (int i = 0; i < mycontaint.size(); i++) {
temp = (RoadGLJ)mycontaint.elementAt(i);
n = n + temp.getShi() + "\t" + temp.getXian() + "\t" + temp.getRoadNumber() + "\t" + temp.getLicheng() + "\r\n";
}
return n;
}
public static void main(String args[]){
OutPutToArray oa = new OutPutToArray();
oa.addData();
// oa.run();
// oa.setData();
// oa.runShi();
oa.createFile(oa.printQu("亳州市","市辖区"),"E:\\temp\\亳州市.txt");
oa.createFile(oa.printQu("池州市","市辖区"),"E:\\temp\\池州市.txt");
oa.createFile(oa.printQu("铜陵市","铜官山区"),"E:\\temp\\铜陵市铜官山区.txt");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -