
com.urbanairship.connect.client.consume.FullBodyConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of connect-client Show documentation
Show all versions of connect-client Show documentation
The UA Connect Java client library
The newest version!
package com.urbanairship.connect.client.consume;
import com.google.common.base.Supplier;
import com.urbanairship.connect.java8.Consumer;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
public final class FullBodyConsumer implements Consumer, Supplier {
private final ByteArrayOutputStream bytes = new ByteArrayOutputStream();
@Override
public void accept(byte[] data) {
try {
bytes.write(data);
}
catch (IOException e) {
throw new RuntimeException("Error writing bytes to memory", e);
}
}
@Override
public String get() {
return bytes.size() == 0
? ""
: new String(bytes.toByteArray(), StandardCharsets.UTF_8);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy