Search in sources :

Example 1 with DataOutputStream

use of org.apache.nifi.stream.io.DataOutputStream in project nifi by apache.

the class SnippetManager method export.

public byte[] export() {
    try (final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final DataOutputStream dos = new DataOutputStream(baos)) {
        for (final StandardSnippet snippet : getSnippets()) {
            final byte[] bytes = StandardSnippetSerializer.serialize(snippet);
            dos.writeInt(bytes.length);
            dos.write(bytes);
        }
        return baos.toByteArray();
    } catch (final IOException e) {
        // won't happen
        return null;
    }
}
Also used : DataOutputStream(org.apache.nifi.stream.io.DataOutputStream) ByteArrayOutputStream(org.apache.nifi.stream.io.ByteArrayOutputStream) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 ByteArrayOutputStream (org.apache.nifi.stream.io.ByteArrayOutputStream)1 DataOutputStream (org.apache.nifi.stream.io.DataOutputStream)1