if(newFiles[i].lastModified() >= lastScanedTime) {
return true;
}
}
return false ;
}
}
FileTableModel.java
/*
* FileTableModel.java
*
* Created on
*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package DirectoryScanner;
import java.io.File;
import javax.swing.table.AbstractTableModel;
/**
*
* @author Hale Chou
*/
public class FileTableModel extends AbstractTableModel implements FileListener {
private File[] files = null ;
public FileTableModel(File dir) {
files = dir.listFiles();
}
public FileTableModel(File[] ff) {
this.files = ff;
}
public int getRowCount() {
return files.length;
}
// Get a column's name.
@Override
public String getColumnName(int col) {
String s = "文件名,路径,大小,修改时间";
return s.split(",")[col];
}
public int getColumnCount() {
return 4;
}
public Object getValueAt(int rowIndex, int columnIndex) {
File f = files[rowIndex];
if(f.isDirectory()){
f.delete();
}else{
switch(columnIndex){
case 0 :
return f.getName();
case 1 :
return f.getPath();
case 2 :
return ParseUtility.bytes2kb(f.length());
case 3 :
return ParseUtility.toYYYYMMDDHHMMSS(f.lastModified());
}
}
return "";
}
public void dirChanged(FileMonitor monitor) {
this.files = monitor.getMonitoredFile();
fireTableDataChanged();
}
}
ParseUtility.java
/*
* ParseUtility.java
*
* Created on

