Questions tagged [bytearrayoutputstream]

A mechanism for writing byte data to a stream

A ByteArrayOutputStream is a mechanism for writing an array of byte data to a stream. A stream is usually comprised of data to write to a local file, or data being transmitted to a remote server over a network protocol such as HTTP or FTP. This type of stream would send the contents of a byte array, one byte at a time, through the stream to the destination, until the entire array has been sent.

234 questions
3
votes
3 answers

Android Image size after compressed from bitmap is very large than original image load to bitmap

I am now a newbie to android programming. I am very confused when processing with images. I am now trying to load a jpeg image to bitmap and then convert bitmap to byte array and vice versa. I am testing with the first case: load jpeg to bitmap and…
3
votes
0 answers

What is the best way to rebuild a PDDocument(from PDFBox)?

I have a PDDocument object on a WAS and it needs to be transmitted to a client server to be used there. The pddocument is not serializable so I have to find another solution to get it there. I am now thinking of doing this: 1. On the WAS: saving…
3
votes
2 answers

Send packet over UDP socket

I am trying to send the following data to a server, that will be using C++: static int user_id; // 4 Bytes static byte state; // 1 Byte static String cipher_data; // 128 Bytes static String hash; // 128 Bytes static final int PACKET_SIZE =…
3
votes
3 answers

How can I write ByteArrayOutput stream to a file in groovy?

In Java, I can easily use following code, to write a ByteArrayOutputStream to a file. However, try-with-resources doesn't work in Groovy :( ByteArrayOutputStream byteArrayOutputStream = getByteStreamMethod(); try(OutputStream outputStream = new…
3
votes
1 answer

Read from ByteArrayOutputStream while it's being written to

I have a class that is constantly producing data and writing it to a ByteArrayOutputStream on its own thread. I have a 2nd thread that gets a reference to this ByteArrayOutputStream. I want the 2nd thread to read any data (and empty) the…
Mike
  • 609
  • 12
  • 36
3
votes
1 answer

Why ByteArrayOutputStream and ByteArrayInputStream not the same content?

I have a big problem during one of my unit tests in Java. I compare a byte array with an InputStream and I do not get the same result. The example is below. public final class ByteGetInputStreamExampleProblem { public static void main( final…
Skaÿ
  • 326
  • 1
  • 3
  • 15
3
votes
4 answers

ByteArrayOutputStream to PrintWriter (Java Servlet)

Writing generated PDF (ByteArrayOutputStream) in a Servlet to PrintWriter. I am desperately looking for a way to write a generated PDF file to the response PrintWriter. Since a Filter up the hierarchy chain has already called response.getWriter() I…
3
votes
1 answer

yuv.compressToJpeg does not accept ByteArrayOutputStream?

I am trying to convert the byte [] data that I am receiving in onPreviewFrame to jpeg using the following code. ByteArrayOutputStream baos = new ByteArrayOutputStream(); YuvImage yuv = new YuvImage(data, ImageFormat.NV21, previewWidth,…
Jag
  • 517
  • 2
  • 5
  • 17
3
votes
1 answer

Convert ByteArrayOutputStream to BufferedImage

I have a ByteArrayOutputStream I have created using the QRGen Qr code generation library, and I want to turn it into a BufferedImage object and present it in an ImageView in Android. How may that be achieved?
Iddo Gino
  • 342
  • 2
  • 11
3
votes
3 answers

Fastest way to GZIP and UDP a large amount of Strings in Java

I'm implementing a logging system that needs to encode the log messages with GZIP and send them off by UDP. What I've got so far is: Initialization: DatagramSocket sock = new DatagramSocket(); baos = new ByteArrayOutputStream(); printStream = new…
Kristaps Baumanis
  • 563
  • 1
  • 7
  • 18
3
votes
2 answers

How can I remove bytes from a ByteArrayOutputStream?

So the first four bytes of my ByteArrayOutputStream contain the length of a header in my stream. I need to remove that header from the stream and go on with my business. ByteArrayOutputStream oStream = new ByteArrayOutputStream(); /* populate…
Grammin
  • 11,808
  • 22
  • 80
  • 138
3
votes
4 answers

How is this 13 bytes long?

Two quotes: All of the remaining messages in the protocol take the form of . The length prefix is a four byte big-endian value. The message ID is a single decimal byte. The payload is message dependent. request:…
Hamza Yerlikaya
  • 49,047
  • 44
  • 147
  • 241
2
votes
2 answers

out of memory Error while writing ByteArrayOutputStream in Android

I have a big problem, that I am reading 2^21 bytes from a video file which resides in Sdcard but when we write the same in ByteArrayOutputStream it throws an Exception as Out of Memory. I don't know why? Please suggest the right solution for the…
Sanat Pandey
  • 4,081
  • 17
  • 75
  • 132
2
votes
1 answer

android record mic to ByteArray and stream to server via socket

I am a beginner for kotlin and android application. I would like to record voice continously and pass the voice data to server via socket. I tried the code below but the server ended up receiving data in AMR format only. val byteArrayOutputStream =…
2
votes
2 answers

Swagger-Codegen generates empty class instead of an instance of ByteArrayOutputStream

I'm currently trying to generate an api with swagger-codegen. The only problem i have is that swagger generates an empty class with the name "ByteArrayOutputStream" instead of an instance of ByteArrayOutputStream. The generated class also contains…
fbnrbn
  • 381
  • 1
  • 4
  • 9
1 2
3
15 16