java - How to store a list of strings in a single ZooKeeper znode using Curator -


for example, there znode path a/b/c/d. i'd store list of strings on znode. obviously, use join list of strings single string , serialize byte array this:

curator.create()             .creatingparentcontainersifneeded()             .forpath(path, value.getbytes(standardcharsets.utf_8)); 

but looks not convenient. there other approach?

the easiest/best way use apacheutils:

byte[] input = serializationutils.serialize(yourlist); curator.create()         .creatingparentcontainersifneeded()         .forpath(path, input); 

and out:

byte[] output = curator.getdata().forpath(path); list<string> newlist = (list<string>)serializationutils.deserialize(output); 

this rather general aproach work java objects.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -