Java Code Examples for org.redisson.api.RBinaryStream#getOutputStream()
The following examples show how to use
org.redisson.api.RBinaryStream#getOutputStream() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BinaryStreamExamples.java From redisson-examples with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws IOException { // connects to 127.0.0.1:6379 by default RedissonClient redisson = Redisson.create(); RBinaryStream stream = redisson.getBinaryStream("myStream"); byte[] values = new byte[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; stream.trySet(values); stream.set(values); InputStream is = stream.getInputStream(); StringBuilder sb = new StringBuilder(); int ch; while((ch = is.read()) != -1) { sb.append((char)ch); } String str = sb.toString(); OutputStream os = stream.getOutputStream(); for (int i = 0; i < values.length; i++) { byte c = values[i]; os.write(c); } redisson.shutdown(); }
Example 2
Source File: RedissonBinaryStreamTest.java From redisson with Apache License 2.0 | 6 votes |
@Test public void testWriteArrayWithOffset() throws IOException { RBinaryStream stream = redisson.getBinaryStream("test"); OutputStream os = stream.getOutputStream(); byte[] value = {1, 2, 3, 4, 5, 6}; os.write(value, 0, 3); byte[] s = stream.get(); assertThat(s).isEqualTo(new byte[] {1, 2, 3}); os.write(value, 3, 3); s = stream.get(); assertThat(s).isEqualTo(value); }
Example 3
Source File: RedissonBinaryStreamTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testWriteArray() throws IOException { RBinaryStream stream = redisson.getBinaryStream("test"); OutputStream os = stream.getOutputStream(); byte[] value = {1, 2, 3, 4, 5, 6}; os.write(value); byte[] s = stream.get(); assertThat(s).isEqualTo(value); }