📄 opendirect.java
字号:
package net.aetherial.gis.jiaotongbu.input.analyse;
import java.util.Vector;
import java.io.File;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2004</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class OpenDirect {
private String gradeStr = "国道|省道|县道|乡道";
public OpenDirect() {
}
public File[] getAllGPSFiles(String inputPath) {
Vector ve = getShunxuFile(this.findOutGPSFiles(inputPath));
File[] temp = new File[ve.size()];
ve.copyInto(temp);
return temp;
}
public static String getSplashPath(String inputPath) {
if (inputPath.trim().endsWith("\\")) {
return inputPath;
}
else if (inputPath.trim().endsWith("/")) {
return inputPath;
}
else {
return inputPath + "\\";
}
}
private Vector getShunxuFile(Vector files) {
String[] shunxu = {
"G", "S", "X", "Y", "C", "Z"};
Vector temp = new Vector();
int length = files.size();
for (int i = 0; i < length; i++) {
if ( ( (File) files.get(i)).getName().toUpperCase().startsWith(shunxu[0])) {
temp.add(files.get(i));
}
}
for (int i = 0; i < length; i++) {
if ( ( (File) files.get(i)).getName().toUpperCase().startsWith(shunxu[1])) {
temp.add(files.get(i));
}
}
for (int i = 0; i < length; i++) {
if ( ( (File) files.get(i)).getName().toUpperCase().startsWith(shunxu[2])) {
temp.add(files.get(i));
}
}
for (int i = 0; i < length; i++) {
if ( ( (File) files.get(i)).getName().toUpperCase().startsWith(shunxu[3])) {
temp.add(files.get(i));
}
}
for (int i = 0; i < length; i++) {
if ( ( (File) files.get(i)).getName().toUpperCase().startsWith(shunxu[4])) {
temp.add(files.get(i));
}
}
for (int i = 0; i < length; i++) {
if ( ( (File) files.get(i)).getName().toUpperCase().startsWith(shunxu[5])) {
temp.add(files.get(i));
}
}
String name = "";
for (int i = 0; i < length; i++) {
name = ( (File) files.get(i)).getName().toUpperCase();
if ( (!name.startsWith(shunxu[0])) && (!name.startsWith(shunxu[1])) &&
(!name.startsWith(shunxu[2])) && (!name.startsWith(shunxu[3])) &&
(!name.startsWith(shunxu[4])) && (!name.startsWith(shunxu[5]))) {
temp.add(files.get(i));
}
}
return temp;
}
public static String getKuaxianFile(String inputPath) {
File base = new File(inputPath);
File[] all = base.listFiles();
File[] temp = null, temp1 = null;
for (int i = 0; all != null && i < all.length; i++) {
if (all[i].getName().indexOf("年报核对") != -1 && all[i].isDirectory()) {
temp = all[i].listFiles();
for (int j = 0; temp != null && j < temp.length; j++) { //年报核对表\程序输出信息
if (temp[j].getName().indexOf("程序输出信息") != -1 ||
temp[j].getName().indexOf("程序输出") != -1) {
temp1 = temp[j].listFiles();
for (int k = 0; temp1 != null && k < temp1.length; k++) {
if (temp1[k].getName().indexOf("跨县") != -1) {
return temp1[k].getAbsolutePath();
}
}
}
}
}
}
return null;
}
public static String getXian(File gpsFile) {
return gpsFile.getParentFile().getParentFile().getParentFile().getName();
}
public File getLuduanExcel(String inputPath) {
File base = new File(inputPath);
File[] all = base.listFiles();
File[] temp = null;
for (int i = 0; all != null && i < all.length; i++) {
if (all[i].getName().indexOf("年报核对") != -1 && all[i].isDirectory()) {
temp = all[i].listFiles();
for (int j = 0; temp != null && j < temp.length; j++) {
if (temp[j].getName().indexOf("1_路段比较表") != -1 ||
temp[j].getName().indexOf("路段") != -1) {
return temp[j];
}
}
}
}
return null;
}
public File getQiaoliangExcel(String inputPath) {
File base = new File(inputPath);
File[] all = base.listFiles();
File[] temp = null;
for (int i = 0; all != null && i < all.length; i++) {
if (all[i].getName().indexOf("年报核对") != -1 && all[i].isDirectory()) {
temp = all[i].listFiles();
for (int j = 0; temp != null && j < temp.length; j++) {
if (temp[j].getName().indexOf("8_桥梁信息汇总表") != -1 ||
temp[j].getName().indexOf("汇总") != -1) {
return temp[j];
}
}
}
}
return null;
}
public String getArrayPath(String inputPath) {
File f = new File(inputPath);
File[] children = f.listFiles();
if (children != null) {
if (children.length >= 11) {
if (this.hasFile("cun.txt", children) &&
this.hasFile("xiangzhen.txt", children)) {
return getSplashPath(f.getAbsolutePath());
}
}
String temp = "";
for (int i = 0; i < children.length; i++) {
if (children[i].isDirectory()) {
temp = getArrayPath(children[i].getAbsolutePath());
if (!(temp.equals(""))) {
return temp;
}
}
}
}
return "";
}
private boolean hasFile(String fileName, File[] children) {
for (int i = 0; children != null && i < children.length; i++) {
if (children[i].getName().indexOf(fileName) != -1) {
return true;
}
}
return false;
}
private Vector findOutGPSFiles(String inputPath) {
Vector gpsFiles = new Vector();
//String gradeDir = "";
File base = new File(inputPath);
File[] all = base.listFiles();
for (int i = 0; all != null && i < all.length; i++) {
if (all[all.length - i - 1].isDirectory()) {
// System.out.println(all[i].getAbsolutePath());
gpsFiles.addAll(findOutGPSFiles(all[i].getAbsolutePath()));
}
}
File[] gps = base.listFiles(new java.io.FilenameFilter() {
public boolean accept(File file, String name) {
return
file != null &&
checkGradePath(file.getAbsolutePath(), gradeStr) &&
name.length() > 4 &&
".gps".equalsIgnoreCase(name.substring(name.length() - 4));
}
});
for (int i = 0; gps != null && i < gps.length; i++) {
if (gps[i] == null) {
System.err.println("gps[" + i + "] == null");
}
gpsFiles.add(gps[i]);
}
return gpsFiles;
}
private boolean checkGradePath(String path, String gradeStr) {
boolean result = false;
if (gradeStr.indexOf("非") != -1) {
return false;
}
if (gradeStr.length() == 0) {
result = path.indexOf("整理完毕") > -1;
}
else {
if (gradeStr.indexOf("国道") > -1) {
result |= path.indexOf("整理完毕\\国") > -1;
}
if (gradeStr.indexOf("省道") > -1) {
result |= path.indexOf("整理完毕\\省") > -1;
}
if (gradeStr.indexOf("县道") > -1) {
result |= path.indexOf("整理完毕\\县") > -1;
}
if (gradeStr.indexOf("乡道") > -1) {
result |= path.indexOf("整理完毕\\乡") > -1;
}
if (gradeStr.indexOf("村道") > -1) {
result |= path.indexOf("整理完毕\\村") > -1 || path.indexOf("整理完毕\\乡村") > -1;
}
if (gradeStr.indexOf("专用道路") > -1) {
result |= path.indexOf("整理完毕\\专") > -1;
}
}
return result;
}
public void setGradeStr(String gradeStr) {
this.gradeStr = gradeStr;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -