Reading config file in aar archive on Tomcat with Axis2(aar中讀配置文件)

1. Put your config file inside lib directory populated on aar file.

2. Using:
InputStream in=getClass().getClassLoader().getResourceAsStream("Test.properties");
which will load the property file into memory.

3. for instance:

public String testResourceReader() {
    Properties p=new Properties();
    InputStream in=getClass().getClassLoader().getResourceAsStream("Test.properties");
    try {
        p.load(in);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return p.toString();
}

Result:

<ns:testResourceReaderResponse>
<ns:return>{name=test name, file=file1}</ns:return>
</ns:testResourceReaderResponse>

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章