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
0
votes
2 answers

java insert Blob as ByteArrayOutputStream get ClassCastException

I've to save a pdf file represented as a ByteArrayOutputStream into a Blob SQL field of a table, here's my code: public boolean savePDF(int version, ByteArrayOutputStream baos) throws Exception{ boolean completed = false; ConnectionManager…
Fseee
  • 2,476
  • 9
  • 40
  • 63
0
votes
2 answers

Socket Inputstream doesn't return -1 at the end of stream

This is a code snippet where the problem is happening: public static byte[] copyLargeExt(InputStream input) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buffer = new byte[1024*8]; int…
0
votes
3 answers

Outofmemoryerror ByteArrayOutputStream sending large file to WS

im sending videos to webservice and works ok with videos less than 10MB, if the video is about 12MB give me outofmemoryerror: This is my code: FileInputStream fileInputStream = new FileInputStream(fichero); int bytesAvailable =…
rbrlnx
  • 286
  • 7
  • 23
0
votes
3 answers

Adding up ByteArrayOutputStreams

Im having a bunch of ByteArrayOutputstreams onto which pdf reports are written over different parts of a particular workflow. I use IText to accomplish this. Now, at the end I would like to group all these single ByteArrayOutputstreams into a bigger…
ping
  • 1,229
  • 3
  • 21
  • 41
0
votes
3 answers

Would java.io.ByteArrayOutputStream.toByteArray() return null?

Just like the title shows, I couldn't find any clue about it in Javadoc.
rkk
  • 189
  • 2
  • 11
-1
votes
2 answers

Handle large file (>2GB) in the ByteArrayInputStream

I am getting a very large file(>2.5GB) data in a ByteArrayInputStream format from other method. This data I have to pass to another method in a InputStream format. I have written the following code which executes fine for smaller file, but it fails…
-1
votes
1 answer

Getting Object back from an ObjectOutputStream

I have created an ObjectOutputStream ObjectOutputStream stream = new ObjectOutputStream(new ByteArrayOutputStream()); stream.writeObject(myObject); but how do I now convert this back into an Object, or even a ByteArray? I've tried getting an…
Wayneio
  • 3,466
  • 7
  • 42
  • 73
-1
votes
1 answer

Trouble generating over 200MB file into ZIP using ByteArrayOutputStream and ZipOutputStream

I need your help again. My application trying to export user's files (settings, processes, standard files, etc.) as ZIP. This exported ZIP will be used later to import user's files in other system. So far I have done following code: def files =…
-1
votes
2 answers

ByteArrayOutputStream performance

My requirement is to create 2 copies of the inputstream, one for Apache Tika File MimeType Detect and another to Output Stream. private List copyInputStream(final InputStream pInputStream, final int numberOfCopies) throws…
-1
votes
1 answer

Accept only part of message written to ByteArrayOutputStream object

I'm trying to get raw xml of SOAPMessage object and I'm doing that using ByteArrayOutputStream class, but its losing readability once there's compressed attachment added to the message object. Here's my code: ByteArrayOutputStream out = new…
erhesto
  • 1,176
  • 7
  • 20
-1
votes
2 answers

ByteArrayOutputStream .toByteArray(); Exception

when i tryin to make thme method .toByteArray(); always fall in a exception, but the log doesn´t show, what can be the problem: protected byte[] GetResponseBytes(HttpURLConnection conn) { byte[] data2 = null; try { int nRead; …
-1
votes
1 answer

Returning big size byte array or using ByteArrayOutputStream

My question is with big size byte array (from 10k bytes), should I return direct the byte array value like this: byte[] my_function() { ... return value; } or use ByteArrayOutputStream/OutputStream as an param? void…
Anh-Tuan Mai
  • 1,129
  • 19
  • 36
-1
votes
2 answers

compress file with Java ByteArrayOutputstream

I am trying to compress file with Java ByteArrayOutputstream,but I failed.If I change the ouputstream to FileOutput stream,it can work.What should I do to make it work?and why? Here is my code(Sorrry,my english is so poor): import…
showstone
  • 1
  • 1
-1
votes
1 answer

checking equality of string containing characters such as "-","+","/" fails

I'm trying to check console output by redirecting the standard output to a ByteArrayOutputStream object. I found this little code snipped that lets me do just that. However, usage of characters such as "-","+" etc. fail the tests. I was wondering…
apil.tamang
  • 2,545
  • 7
  • 29
  • 40
-1
votes
1 answer

ByteArrayOutputStream throwing OutOfMemoryError

I'm trying to read a byte array of an image using the following code but it throws an out of memory exception. I have commented where the exception occurs. byte[] bBuffer = new byte[300000]; // ByteArrayBuffer baf = new ByteArrayBuffer(300000); int…
Mr.Noob
  • 1,005
  • 3
  • 24
  • 58
1 2 3
15
16