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

📄 scanfile.java

📁 基于Java的地图数据管理软件。使用MySQL数据库管理系统。
💻 JAVA
字号:
package net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.module.gpsdata;

import java.io.File;
import java.util.Vector;
import net.aetherial.gis.our.FrameOur;
import org.w3c.dom.Node;
import net.aetherial.gis.surface.ItemValue;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ScanFile {
  private String errorString = "";
  private String gpsDataPath = "";
  public ScanFile(String gpsDataPath) {
    this.gpsDataPath = gpsDataPath;
  }

  public File[] allFile = null;

  /**
   * 检查目录下的文件是否有后缀名不是:".gps",
   * 如果全部通过,返回true;
   * 检查得到的信息存储在errorString里面
   */
  public boolean check(){
    this.allFile = this.getallFile(new File(this.getWithSplash(this.gpsDataPath)));
    boolean isOK = true;
    if (allFile == null) {
      this.errorString = this.errorString + "整理完毕目录下没有文件.\r\n";
      return false;
    }
    for (int i = 0; i < this.allFile.length; i++) {
      if (!(isSuffixWith(this.allFile[i],".gps"))) {
        isOK = false;
        this.errorString = this.errorString + "文件:[" + this.allFile[i].getAbsolutePath() + "]文件后缀名不对!\r\n";
      }
    }
    this.printAllFile();
    return isOK;
  }

  private void printAllFile(){
    for (int i = 0;this.allFile != null && i < this.allFile.length; i++) {
      if (i % 10 ==0) {
        System.out.println("");
      }
      System.out.print(" " + this.allFile[i].getName());
    }
  }

  public void removeAllCunDaoFile(){
    Vector temp = new Vector();
    String name = "";
    for (int i = 0;this.allFile != null && i < this.allFile.length; i++) {
      name = this.allFile[i].getName().toUpperCase().replaceAll(".GPS","");
      System.out.print("   " + name);
      if (name.indexOf("G") != -1 || name.indexOf("S") != -1 || name.indexOf("X") != -1 || name.indexOf("Y") != -1 ) {
        temp.add(this.allFile[i]);
      }
    }
    this.allFile = new File[temp.size()];
    temp.copyInto(this.allFile);
    this.printAllFile();
  }

  public String getErrorString(){
    return this.errorString;
  }

  public File[] getAllFiles(){
    return this.allFile;
  }

  private boolean isSuffixWith(File f, String suffix){
    String name = f.getName();
    if (name.length() <5) {
      return false;
    }else{
      String suff = name.substring(name.length()-4,name.length()).toLowerCase();
      if (suff.equals(suffix)) {
        return true;
      }else{
        return false;
      }
    }
  }

  private String getWithSplash(String path){
    if (path.endsWith("\\")) {
      return path;
    }else if(path.endsWith("/")){
      return path;
    }else{
      return path + "\\";
    }
  }
  /**
   * 得到所有的文件
   */
  private File[] getallFile(File direct){
    Vector tempve = new Vector();
    File[] Temp = direct.listFiles();
    File[] t = null;
    if(Temp == null){
      return null;
    }else{
      for (int i = 0; i < Temp.length; i++) {
        if (Temp[i].isDirectory()) {
          t = getallFile(Temp[i]);
          if (t != null) {
            for (int j = 0; j < t.length; j++) {
              tempve.add(t[j]);
            }
          }
        }else if(Temp[i].isFile()){
          tempve.add(Temp[i]);
        }
      }

      File[] temp = null;
      if (tempve.size() == 0) {
        return null;
      }
      else {
        temp = new File[tempve.size()];
        for (int i = 0; i < tempve.size(); i++) {
          temp[i] = (File) tempve.elementAt(i);
        }
      }
      return temp;

    }
  }

  public static void main(String args[]){
    ScanFile sf = new ScanFile("D:\\数据备份同步\\11试点县\\数据\\桐城县\\数据\\所有文件\\");
    System.out.println("check...");
    sf.check();
    System.out.println("check...End");
    FrameOur fo = new FrameOur();
    String temp = "",n = "";
    for (int i = 0; i < sf.allFile.length; i++) {
      if (sf.allFile[i].getName().endsWith(".gps")) {
        fo.openFile(sf.allFile[i]);
        Node[] trks = ItemValue.getTracks();
        if (trks != null) {
          for (int j = 0; j < trks.length; j++) {
            temp = ItemValue.getTracksNumber(trks[j]);
            if (temp.length() == 10) {
              n = n + sf.allFile[i].getAbsolutePath() + ":->******************" + temp;
              System.out.println(sf.allFile[i].getAbsolutePath() + ":->******************" + temp);
            }
          }
        }
        fo.reset();
      }
    }
    System.out.println(n);

  }
}

⌨️ 快捷键说明

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