Repository navigation
Expand file tree
/
Copy pathDoc.java
More file actions
77 lines (63 loc) · 1.74 KB
/
Copy pathDoc.java
File metadata and controls
77 lines (63 loc) · 1.74 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
package javaSystem;
import java.io.*;
import java.sql.Timestamp;
public class Doc implements Serializable{
private String ID;//文件的标识
private String creator;//创建者
private Timestamp timestamp;//时间记录
private String description;//文件描述
private String filename;//源文件名
public Doc(String ID, String creator, Timestamp timestamp, String description, String filename) {
super();
this.ID = ID;
this.creator = creator;
this.timestamp = timestamp;
this.description = description;
this.filename=filename;
}
public Doc() {
}
public String getID() {
return ID;
}
public void setID(String iD) {
ID = iD;
}
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
public Timestamp getTimestamp() {
return timestamp;
}
public void setTimestamp(Timestamp timestamp) {
this.timestamp = timestamp;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public static String getFileName(String filename) { //获取文件名
if ((filename != null) && (filename.length() > 0)) {
int split = filename.lastIndexOf('\\'); //由于\\属于转义符,所以\\实际为\在字符床长度计算中只算一
//且索引从0开始
if (split == -1) {//如果字符串中无\\则获取/的位置
split = filename.lastIndexOf('/');
}
if ((split >-1) && (split < (filename.length() - 1))) {
return filename.substring(split + 1);
}
}
return filename;
}
}