📄 scanpath.java
字号:
package net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.view.scan;
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 ScanPath {
private String pathArray = "";
private String pathWanbi = "";
private String pathBaobiao = "";
private String pathOut = "";
public ScanPath() {
}
public void setPathArray(String pathArray){
this.pathArray = pathArray;
}
public void setPathWanbi(String pathWanbi){
this.pathWanbi = pathWanbi;
}
public void setPathBubao(String pathBaobiao){
this.pathBaobiao = pathBaobiao;
}
public void setPathOut(String pathOut){
this.pathOut = pathOut;
}
public File[] getPathsBaobiaos(){
File[] paths = new File[7];
String parent = this.getSplashPath(this.pathBaobiao);
File f = new File(parent);
File[] children = f.listFiles();
if (children != null) {
paths[0] = findFileWithKey("乡镇","表-1","表1",children);
paths[1] = findFileWithKey("建制村","表-2","表2",children);
paths[2] = findFileWithKey("桥梁","表-3","表3",children);
paths[3] = findFileWithKey("隧道","表-4","表4",children);
paths[4] = findFileWithKey("渡口","表-5","表5",children);
paths[5] = findFileWithKey("填报人员","表-7","表7",children);
paths[6] = findFileWithKey("乡镇交界点坐标","表-8","表8",children);
return paths;
}else{
return null;
}
}
public String[] getPathsBaobiaosString(){
File[] paths = getPathsBaobiaos();
if (paths != null) {
String[] temp = new String[paths.length];
for (int i = 0; i < temp.length; i++) {
if (paths[i] != null) {
temp[i] = paths[i].getAbsolutePath();
}else{
temp[i] = "";
}
}
return temp;
}else{
return null;
}
}
public File getPathArray(){
return new File(getSplashPath(this.pathArray));
}
public File getPathWanbi(){
return new File(getSplashPath(this.pathWanbi));
}
public File getPathOut(){
return new File(getSplashPath(this.pathOut));
}
public Object[] getPathArrayObject(){
Object[] ob = new Object[2];
ob[0] = "Array 路径:";
if (this.pathArray.equals("")) {
ob[1] = "";
}else{
ob[1] = getSplashPath((new File(this.pathArray)).getAbsolutePath());
}
return ob;
}
public Object[] getPathOutObject(){
Object[] ob = new Object[2];
ob[0] = "输出 路径:";
if (this.pathArray.equals("")) {
ob[1] = "";
}else{
ob[1] = getSplashPath((new File(this.pathOut)).getAbsolutePath());
}
return ob;
}
public Object[] getPathWanbiObject(){
Object[] ob = new Object[2];
ob[0] = "整理完毕 路径:";
if (this.pathArray.equals("")) {
ob[1] = "";
}else{
ob[1] = getSplashPath((new File(this.pathWanbi)).getAbsolutePath());
}
return ob;
}
public Object[][] getPathsBaobiaosObject(){
Object[][] ob = new Object[7][2];
File[] paths = this.getPathsBaobiaos();
if (paths != null) {
ob[0][0] = "表1-乡镇基本信息表:";
if (paths[0] != null) {
ob[0][1] = paths[0].getName();
}
else {
ob[0][1] = "";
}
ob[1][0] = "表2-建制村基本信息表:";
if (paths[1] != null) {
ob[1][1] = paths[1].getName();
}
else {
ob[1][1] = "";
}
ob[2][0] = "表3-桥梁基本信息表:";
if (paths[2] != null) {
ob[2][1] = paths[2].getName();
}
else {
ob[2][1] = "";
}
ob[3][0] = "表4-隧道基本信息表:";
if (paths[3] != null) {
ob[3][1] = paths[3].getName();
}
else {
ob[3][1] = "";
}
ob[4][0] = "表5-渡口基本信息表:";
if (paths[4] != null) {
ob[4][1] = paths[4].getName();
}
else {
ob[4][1] = "";
}
ob[5][0] = "表7-填报人员联系表:";
if (paths[5] != null) {
ob[5][1] = paths[5].getName();
}
else {
ob[5][1] = "";
}
ob[6][0] = "表8-乡镇交界点坐标表:";
if (paths[6] != null) {
ob[6][1] = paths[6].getName();
}
else {
ob[6][1] = "";
}
return ob;
}
return new Object[0][2];
}
private File findFileWithKey(String key1,String key2,String key3,File[] f){
if (f == null) {
return null;
}
for (int i = 0; i < f.length; i++) {
if (f[i].getName().indexOf(key1) != -1) {
return f[i];
}else if (f[i].getName().indexOf(key2) != -1) {
return f[i];
}else if (f[i].getName().indexOf(key3) != -1) {
return f[i];
}
}
return null;
}
/**
* 保证路径的最后一个字符有斜杠
*/
private String getSplashPath(String path){
if ((path.endsWith("\\"))||(path.endsWith("/"))) {
return path;
}else{
return path + "\\";
}
}
public static void main(String[] args) {
// ScanPath scanpath = new ScanPath();
String n = "";
for (int i = 0; i < 6; i++) {
n = n + " ob[" + i +"][0] = \"表" + (i+1) +"\";" + "\r\n";
n = n + " ob[" + i +"][1] = paths[" + i +"].getAbsolutePath();" + "\r\n";
}
System.out.println(n);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -