?? detector.java
字號:
package com.justin.detect;
import java.io.*;
/**
* @author Justin
*
* 監測類,實現監測數據文件的功能
*/
public class Detector {
private File dataDir;
private String[] newFileNames;
private boolean hasNewData;
private boolean isDir;
private String detectFileExt;
public Detector(File dataDir, String detectFileExt) {
this.dataDir = dataDir;
newFileNames = null;
hasNewData = false;
isDir = checkDir();
}
public Detector(String dirName) {
dataDir = new File(dirName);
newFileNames = null;
hasNewData = false;
isDir = checkDir();
}
public boolean checkDir() {
isDir = false;
if (dataDir.exists()) {
if (dataDir.isDirectory()) {
isDir = true;
}
}
return isDir;
}
public boolean detect() {
hasNewData = false;
if (isDir) {
newFileNames = dataDir.list(new DetectFileNameFilter(detectFileExt));
if (newFileNames.length > 0) {
hasNewData = true;
}
}
return hasNewData;
}
public boolean HasNewData() {
return hasNewData;
}
public boolean isIsDir() {
return isDir;
}
public String[] getNewFileNames() {
return newFileNames;
}
public File getDataDir() {
return dataDir;
}
//標記新找到的數據文件,將其重命名為.found文件
public boolean markFoundFile(String fileName){
String foundName = fileName.replaceFirst(detectFileExt, "found");
String path = dataDir.getPath() + "\\";
return new File(path + fileName).renameTo(new File(path + foundName));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -