EdH*_*EdH 13 java windows registry
我一直在使用java.util.prefs.Preferences功能(在Java 8中,在Windows机器上).它可以工作,我可以在其中写入Windows注册表的新密钥.因此,我使用Preferences.systemRoot()来获取系统的Preferences对象,然后使用node()方法获取映射到Windows注册表中的节点的Preferences对象.它创造了很好的东西.
我用于节点的密钥是所有大写字母的字符串("RBI").当我查看Windows注册表中的节点时,它显示为"/ R/B/I",名称中带有正斜杠.
我觉得这很奇怪,所以我挖了一下而且看起来这是故意的.我找到了在Windows环境中提供Preferences实现的类(java.util.prefs.WindowsPreferences),该方法用于构建发送到Windows注册表的值是一个静态方法toWindowsName.在JavaDoc中......
Run Code Online (Sandbox Code Playgroud)/** * Converts value's or node's name to its Windows representation * as a byte-encoded string. * Two encodings, simple and altBase64 are used. * <p> * <i>Simple</i> encoding is used, if java string does not contain * any characters less, than 0x0020, or greater, than 0x007f. * Simple encoding adds "/" character to capital letters, i.e. * "A" is encoded as "/A". Character '\' is encoded as '//', * '/' is encoded as '\'. * The constructed string is converted to byte array by truncating the * highest byte and adding the terminating <tt>null</tt> character. * <p> * <i>altBase64</i> encoding is used, if java string does contain at least * one character less, than 0x0020, or greater, than 0x007f. * This encoding is marked by setting first two bytes of the * Windows string to '/!'. The java name is then encoded using * byteArrayToAltBase64() method from * Base64 class. */
因此,对于大写字母,Simple编码将添加正斜杠.
有谁知道为什么这是必需的?我以为注册表可以处理区分大小写的值,但这似乎表明它不能?
我可以解决这个问题,我只是好奇为什么这样做.
| 归档时间: |
|
| 查看次数: |
1297 次 |
| 最近记录: |