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
-1
votes
1 answer

Problems reading a text file from assets with rare characters (á é à è...)

i have a txt file on assets folder with content with rare characters, for example with this content: Hola Holà holá es un vetélélà Holà holá es un vetélélà Holà holá es un vetélélà Holà holá es un vetélélà Holà holá es un vetélélà And i'm using…
-2
votes
2 answers

how to convert input stream to byte array to string in android

I'm working on RFID serial port. In this I have a source code in that mentioned like this new SerialPort(new File("/dev/ttyS3"), 19200); its working perfect I am getting an output, but not in good encoding I tried all encodings, but it's not…
-2
votes
2 answers

ByteArrayOutputStream : java.lang.OutOfMemoryError for files greater than 2gb

java.io.ByteArrayOutputStream is giving OutOfMemoryError when i am trying to upload a file greater than 2gb. I checked the class and found the following code is causing the issue. private static int hugeCapacity(int minCapacity) { if…
-2
votes
1 answer

Adding two data types in bytearrayoutputstream and printing it

I have used the following code. I just can't seem to get the value of x back from the byte array. Here is my code: int seqNo = 0; ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(bout); …
-2
votes
1 answer

Incompatible types; found: class java.lang.String, required: class java.io.ByteArrayOutputStream

This is a continuation of HTML tags are getting converted When I try to the following ByteArrayOutputStream stream= new ByteArrayOutputStream(); stream= stream.toString().replaceAll("<","<"); I am getting incompatible types; found: class…
Jacob
  • 14,463
  • 65
  • 207
  • 320
-2
votes
2 answers

How to get the size of an empty "unwritten" stream?

I have an stream that is created with a fixed size. The buffer is empty. I want to be able to get the size of this buffer. What is an efficient way of doing this? Here is what I have done. static OutputStream CreateBuffer() { return…
nikk
  • 2,627
  • 5
  • 30
  • 51
-3
votes
1 answer

Return as ByteArrayOutputStream instead of FileOutputStream

I have a requirement to generate PDF file from JSON Objects and am able to produce PDF document using Apache FOP and Java. But i want to return the PDF file as ByteArrayOutputStream and then i have to encode like this…
Karthikeyan
  • 1,927
  • 6
  • 44
  • 109
-3
votes
1 answer

ImageIO write only load half the picture (socket)

I'm trying to send an image from client to server using socket. I am able to send the image to server directory, but the image sent is not full. What should I change? Client code : Part filePart = request.getPart("file"); InputStream fileContent =…
-4
votes
1 answer

Is it OK ByteArrayOutputStream is not closed

I am reading the following Java file: https://svn.apache.org/viewvc/pdfbox/trunk/examples/src/main/java/org/apache/pdfbox/examples/util/PrintTextLocations.java?revision=1709154&view=co In the linked code, the ByteArrayOutputStream is initialized but…
Rui
  • 3,454
  • 6
  • 37
  • 70
1 2 3
15
16