目录文件如下:
我们是使用代码得到errorCode.properties中的文件内容:
0=success
100=邮箱错误
101=密码错误
102=此邮箱已被注册
103=两次密码输入不一致
104=登录失效,请重新登陆
105=旧密码错误
200=创建成功
201=获取失败,请重新登录
202=创建失败
203=删除成功
204=删除失败
205=修改成功
206=修改失败
300=登录失效,请重新登录
301=分享成功
302=删除分享成功
303=得到用户分享列表
304=得到计划圈分享列表失败
400=获取列表成功
401=分享为空
501=评论列表为空
502=加载失败
503=评论失败
602=找不到此计划
603=参加人数超过最大人数
601=你已经加入了此计划
604=参加人数已经达到最大人数
305=该计划已被分享
605=没有权限操作
606=你没有加入该计划
package com.imudges.utils;
/**
* Created by Administrator on 2016/12/10.
*/
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
public class Information {
static private Information instance;
private Information() {
// TODO Auto-generated constructor stub
}
static public Information getInstance() {
if(instance == null)
instance = new Information();
return instance;
}
public String getErrorInfo(int errorCode) {
Properties properties = new Properties();
InputStream in = this.getClass().getResourceAsStream("/errorCode.properties");
try {
properties.load(in);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return properties.getProperty(errorCode + "", "null");
}
public String getConfigInfo(String param){
Properties properties = new Properties();
InputStream in = this.getClass().getResourceAsStream("/config.properties");
try {
properties.load(in);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return properties.getProperty(param, "null");
}
}