⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scanarray.java

📁 基于Java的地图数据管理软件。使用MySQL数据库管理系统。
💻 JAVA
字号:
package net.aetherial.gis.our.allauto.create;

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 ScanArray {
  private final String[] arrayFile = {
      "xiangzhen.txt", "cun.txt", "jinji.txt", "renkou.txt", "shouru.txt",
      "mianji.txt", "zirancun.txt", "dixing.txt", "tiaojian.txt", "dukou.txt",
      "beizhu.txt"};
  private String arrayPath = "";
  public ScanArray(String inputPath) {
    this.find(inputPath);
  }
  /**
   * 得到数组的路径
   */
  public String getArrayPath(){
    return this.arrayPath;
  }
  private void find(String path){
    File f = new File(path);
    if (isArrayExist(path)) {
      this.arrayPath = getEndWithSlash(path);
      return;
    }
    File[] all = f.listFiles();
    if (all == null) {
      return;
    }
    else {
      for (int i = 0; i < all.length; i++) {
        if (all[i].isDirectory()) {
          find(all[i].getAbsolutePath());
        }
//        if (this.isArrayExist(all[i].getAbsolutePath())) {
//          return;
//        }
      }
    }
  }
  /**
   * 判断directory目录下array是否齐全,
   * 如果齐全的话,return true;
   */
  private boolean isArrayExist(String directory) {
    File aFile = null;
    for (int i = 0; i < arrayFile.length; i++) {
      aFile = new File(getEndWithSlash(directory) + arrayFile[i]);
      if (!(aFile.exists())) {
        return false;
      }
    }
    return true;
  }

  /**
   * 得到后面有斜杠的字符串。
   */
  private String getEndWithSlash(String directory) {
    if ( (directory.endsWith("\\")) || (directory.endsWith("/"))) {
      return directory;
    }
    else {
      return directory + "\\";
    }
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -