2008-01-14
在j2me中载入propreties资源
关键字: j2me public Properties load(String res) throws IOException
{
Properties prop = new Properties();
DataInputStream is = null;
try
{
is = new DataInputStream(this.getClass().getResourceAsStream(res));
StringBuffer sb = new StringBuffer();
for (int i = is.read(); i > 0; i = is.read())
{
char c = (char) i;
if (c == '\r' || c == '\n')
{
String line = sb.toString();
if (line != null && !line.equals(""))
{
parseLine(prop, line);
sb = new StringBuffer();
}
}
else
{
sb.append((char) i);
}
}
parseLine(prop, sb.toString());
}
finally
{
if (is != null)
{
try
{
is.close();
}
catch (IOException e) { e.printStackTrace(); }
}
}
return prop;
}
private void parseLine(Properties prop, String line)
{
if (line != null && !line.equals(""))
{
int pos = line.indexOf(":");
prop.addProperty(line.substring(0, pos), line.substring(pos + 2, line.length()));
}
}
发表评论
- 浏览: 5876 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
基于Asp.net mvc preview ...
看了一下,感觉还很好用,准备裁剪后引入验证。辛苦,谢谢。
-- by lzy.je -
在GAE中生成全局序列号
并发没问题吗?
-- by zjumty -
程序员笑话
buaawhl 写道林杰杰 写道估计是把Dec看成了decimal吧。 不过这 ...
-- by sam.ds.chen -
程序员笑话
林杰杰 写道估计是把Dec看成了decimal吧。 不过这个没看懂: How ...
-- by buaawhl -
程序员笑话
keshin 写道几乎所有的硬盘厂商和散存厂商都是按1k=1000算的…… It ...
-- by 林杰杰






评论排行榜