-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMimeTypes.java
More file actions
executable file
·46 lines (38 loc) · 923 Bytes
/
MimeTypes.java
File metadata and controls
executable file
·46 lines (38 loc) · 923 Bytes
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
import java.util.HashMap;
import java.util.Map;
import java.io.IOException;
public class MimeTypes{
HashMap<String,String> types = new HashMap<>();
public MimeTypes(String fileName)throws IOException{
String entries[];
ConfigurationReader cf = new ConfigurationReader(fileName);
while(cf.hasMoreLines() == true){
entries = cf.getEntries();
addType(entries);
}
}
public void addType(String entries[]){
if(entries.length>2 && isComment(entries) == false){
for(int i=1; i<entries.length;i++){
types.put(entries[i],entries[0]);
}
}
}
public void printTypes(){
System.out.println(types);
}
public Boolean isComment(String entries[]){
if(Character.valueOf(entries[0].charAt(0)) == '#'){
return true;
}else{
return false;
}
}
public String lookUp(String extension){
String type = types.get(extension);
if(type == null){
type = "text/text";
}
return type;
}
}