ヴォルデモートを使用してデータを保存しています。私のキーは単語で、値は単語と URL の出現回数です。例えば:
key :question
value: 10, www.stackoverflow.com
string[]
値を渡すために使用しています。しかし、使用しようとしているときに、 java.lang.ClassCastException: [Ljava.lang.String;client.put ("xxxx", valuePair);
を取得して います。java.lang.String にキャストできません。
私のコードは次のようになります
public class ClientExample {
public static void main (String [] args) {
String bootstrapUrl = "tcp://localhost:6666";
ClientConfig cc = new ClientConfig ();
cc.setBootstrapUrls (bootstrapUrl);
String[] valuePair = new String[2];
int val = 1;
String value = new Integer(val).toString();
valuePair[0]=value;
valuePair[1] = "www.cnn.com";
System.out.println("Executed one");
StoreClientFactory factory = new SocketStoreClientFactory (cc);
StoreClient <String, String[]> client = factory.getStoreClient ("test");
System.out.println("Executed two");
client.put ("xxxx", valuePair);
System.out.println("Executed three");
String[] ans = client.getValue("key");
System.out.println("Executed four");
System.out.println ("value " +ans[0] +ans[1]);
System.out.println("Executed 5");
}
}