我写了个小工具,其中有个解析txt文件。
文件内容格式:
xxx=xxx
key=value
如a.txt:
LabelEmailAddress=Email Address
Action=Action
LabelPrimaryEmailAddress=Primary Email Address
LabelOtherEmailAddress=Other Email Address
解析结果发现a.txt的[b]第一行[/b]解析出来的key都会带一个小点。我在eclipse中打印这个key很正常,拷贝到sqldeveloper中就多个小点(多这个点,记录死都插入不进去,因为此字段限制了只能是字母),百思不得其解。晕,看图!
JDK自带的Properties类就是用来解析这种key=value形式的文件的。你是用这个解析的吗?
还有就是注意一下编码是否一致。
Properties property = new Properties();
FileInputStream inputFile = null;
// 实例化inputFile
inputFile = new FileInputStream(this.fileName);
// 装载配置文件
property.load(inputFile);
Set<String> keys = property.keySet();
Map<String, String> keyValue = new HashMap<String, String>();
for (String key : keys)
keyValue.put(key, property.getProperty(key));
Property.propertyMap.put(key, value);
你用JDK自带的这个试试看呢
这个得检查你的sqldeveloper的字符集啊啊···