我的应用需要生成十六进制字符串以用作会话ID.Java SecureRandom似乎不起作用("java/lang/NoClassDefFoundError:java/security/SecureRandom:无法在系统包中创建类")
我想做这样的事情:
byte[] resBuf = new byte[50];
new Random().nextBytes(resBuf);
String resStr = new String(Hex.encode(resBuf));
Run Code Online (Sandbox Code Playgroud)
但由于nextBytes(byte[] bytes)某种奇怪的原因,该方法无法使用.
有没有人有可能在Java ME/J2ME中生成随机十六进制数?
非常感谢.
编辑:上面的生成器似乎在使用Bouncy Castle lcrypto-j2me-145(但不是lcrypto-j2me-147)时有效.
我正在尝试反序列化以下Json响应(使用Json.NET):
[{"pollid":"1", "question":"This is a test", "start":"2011-06-28", "end":"2012-03-21", "category":"Roads", "0":"Yes", "1":"No"} … ]
Run Code Online (Sandbox Code Playgroud)
进入这种类型的对象:
class Poll
{
[JsonProperty("pollid")]
public int pollid { get; set; }
[JsonProperty("question")]
public string question { get; set; }
[JsonProperty("start")]
public DateTime start { get; set; }
[JsonProperty("end")]
public DateTime end { get; set; }
[JsonProperty("category")]
public string category { get; set; }
// PROBLEM AREA
[JsonProperty("0")] // Json parameter names are 0 to 9. How can I 'match' these to the List elements?
public List<string> …Run Code Online (Sandbox Code Playgroud)