-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyFile.java
More file actions
88 lines (67 loc) · 2.02 KB
/
MyFile.java
File metadata and controls
88 lines (67 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package FileSystem;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
public class MyFile {
private File myFile;
private String blockName; //文件所在盘区
private FCB fcb = new FCB();
public MyFile(File myFile, String blokName, double capacity){
this.myFile = myFile;
fcb.fileName = myFile.getName();
fcb.isDir = myFile.isDirectory();
fcb.filePath = myFile.getPath();
fcb.capacity = capacity;
this.blockName = blokName;
String ctime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date());
fcb.createTime = ctime;
fcb.lastUpdateTime = ctime;
}
public String getFileName(){
return fcb.fileName;
}
public String getFilePath(){
return fcb.filePath;
}
public boolean renameFile(String name){
String parentPath = myFile.getParent();
File mm = new File(parentPath + File.separator + name);
if (myFile.renameTo(mm)){
myFile = mm;
fcb.fileName = name;
return true;
}else{
return false;
}
}
public File getMyFile(){
return myFile;
}
public String getBlockName() {
return blockName;
}
public double getCapacity() {
return fcb.capacity;
}
public String getCreateTime(){
return fcb.createTime;
}
public String getLastUpdateTime(){
return fcb.lastUpdateTime;
}
public void setLastUpdateTime(String time){
fcb.lastUpdateTime = time;
}
@Override
public String toString(){
return fcb.fileName;
}
class FCB{
public String fileName; //文件名
public boolean isDir; //文件类型
public String filePath; //文件地址
public double capacity; //文件大小
public String createTime; //创建时间
public String lastUpdateTime; //最近修改时间
}
}