arsenal
arsenal

Reputation: 24144

Load the properties file to get the key value pair

PasswordBlurb7=\u4E0D\u53EF\u4F7F\u7528\u91CD\u8907\u5B57\u5143\uFF08\u4F8B\u5982 aaa64135\u3001111bcxjk\uFF09

One of my properties file contains the above key=value pair. So when I try to load this key. I do not get the value. I get ???????? in the value

  Properties prop = new Properties();
  InputStream in = application.getResourceAsStream("WEB-INF/classes/content/"+line);
String value;
prop.load(in); 
for(Object str: prop.keySet()) {
            value = prop.getProperty((String) str);
            hashMap.put((String)str, value);

}

So in the value I get like this--

??????????? aaa64135?111bcxjk? 

I am outputting like this--

<html>
<head>
</head>
<body>
<table border='2'>
<tr>
<th>Key</th>
<th>Values</th>
</tr>
<%
                        for (Entry<String, String> entry : hashMap.entrySet()) {
                                        String key = entry.getKey();
                                        String value = entry.getValue();
%>
<tr><td>
<% out.println(key); %>
</td>
<td>
<% out.println(value);  %>
</td></tr>
<%                                                      }
                        //out.println(hashMap);
                        } catch (FileNotFoundException e1) {
                                    e1.printStackTrace();
                        }
                        catch (IOException e) {
                                    e.printStackTrace();
                        } finally {

                        }

%>
</table>
</body>
</html>

Anything wrong with my code..

Upvotes: 0

Views: 3918

Answers (1)

Anders Lindahl
Anders Lindahl

Reputation: 42870

The property is a string containing unicode-escaped characters. The reason you see ?????... is most likely that the output device you are using does not handle unicode, or that it is using a font that does not contain these asian symbols:

\u4E0D\u53EF\u4F7F\u7528\u91CD\u8907\u5B57\u5143\uFF08\u4F8B\u5982 aaa64135\u3001111bcxjk\uFF09 

不可使用重複🈑兇元(例如aaa64135、111bcxjk)

Upvotes: 2

Related Questions