# Streams

HStreamDB stores data in streams, and this page shows how to operate streams using Java SDK.

# Prerequisites

  • Make sure you have HStreamDB running and accessible.
  • Include following import statements:

import io.hstream.HStreamClient;
import io.hstream.Stream;

1
2
3
4

# Connect to a HStreamDB Instance

First, you need to connect to a HStreaDB instance and get a HStreamClient oject.


HStreamClient client = HStreamClient.builder().serviceUrl("SERVER_HOST:SERVER_PORT).build();

1
2
3

# Get a List of Streams

You can get a list of the streams using the HStreamClient.listStreams() method:


for(Stream stream: client.listStreams()) {
  System.out.println(stream.getStreamName());
}

1
2
3
4
5

# Create a New Stream

You can create a new stream using the HStreamClient.createStream() method:


client.createStream("test_stream");

1
2
3

# Delete a Stream

You can delete a stream using the HStreamClient.deleteStream() method:


client.deleteStream("test_stream");

1
2
3