-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigurationReader.java
More file actions
59 lines (38 loc) · 1.77 KB
/
ConfigurationReader.java
File metadata and controls
59 lines (38 loc) · 1.77 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
package practice;
import java.io.*;
import java.util.*;
public class ConfigurationReader {
String file;
char comment;
String delm;
Hashtable ht;
public ConfigurationReader(String file) {
this.file = file;
this.comment = '#'; // 주석 구분자 # 기호.
this.delm = "=>"; // 서버 정보 구분자 = 기호.
ht = new Hashtable(); // 정보를 파싱하여 key, value 쌍으로 저장하기 위한 공간
}
public String getValue(String name) {
// 프로그램 구현 부분 --------------------------- (5점)
// 해쉬테이블의 키에 해당하는 값을 리턴시키도록 구현.
// ---------------------------------------------------------
}
public void parse() throws IOException {
// 프로그램 구현 부분 --------------------------------------(20점)
// 1. 파일로부터 내용을 읽어내어 파싱 하는 부분이다.
// 2. 읽은 첫 글자가 ‘#’ 인 경우는 주석이므로 다음라인을 읽고,
// 3. 주석이 아닌 경우는 서버 정보이므로.. 서버정보 구분자인 delm (“=>”)을
// 이용하여 key, value 를 추출하여 해쉬 테이블에 저장하는 기능을 완성하라.
//---------------------------------------------------------
}
public static void main(String args[]) { // 변경 하지 마세요.
ConfigurationReader cr =
new ConfigurationReader("myserver.ini");
try {
cr.parse();
System.out.println(cr.getValue("port"));
System.out.println(cr.getValue("server"));
System.out.println(cr.getValue("admin"));
} catch (Exception e) { }
}
}