Linked Questions
96 questions linked to/from Convert InputStream to byte array in Java
21
votes
2
answers
54k
views
In Java, how can I convert an InputStream into a byte array (byte[])? [duplicate]
My background is .net, I'm fairly new to Java. I'm doing some work for our company's java team and the architect needs me to implement a method that takes an InputStream (java.io) object. In order ...
13
votes
3
answers
49k
views
Most efficient way to convert InputStream into byte[]? [duplicate]
ChannelBufferInputStream responseStream = (ChannelBufferInputStream) response.getBodyAsStream();
ArrayList<Byte> arrayList = new ArrayList<Byte>();
try {
while (responseStream....
-1
votes
1
answer
18k
views
Generate a PDF using Streams [duplicate]
I am trying to convert an InputStream into a byte array to write it in a file, to generate a PDF.
I have a File type with the url of a PDF, and with that, i have the inputStream of that.
File ...
-1
votes
2
answers
4k
views
Java how to read from an InputStream the incomed size? [duplicate]
byte[] b = new byte[10000];
len = readerIn.read(b); // InputStream
My byte size is 10000, but the InputStream size may be lower or higher. Is there a way to read only the size of data that comes into ...
-4
votes
2
answers
1k
views
Getting bytes[] from inputstream in android gives null value [duplicate]
Trying to get bytes data from inputstream as shown in the below code. But, the bytes variable is null. What might be the reason? FYI- Image is available in the given uri, ...
0
votes
1
answer
886
views
Issue with checking InputStream size [duplicate]
I have a strange issue:
My dropwizard API processes the uploaded file and saves it as a JPEG image
the uploaded file is read as an InputStream.
FormDataBodyPart fileBody is read using @...
0
votes
0
answers
245
views
Servlet getContentLength() returns > 0 but getInputStream().available() returns 0 [duplicate]
I want to build simple servlet that accepts single file via post and write it somewhere. The curl will be like:
$ curl -X POST -H "Content-Type: Application/Octet-Stream" --data-binary @thrw.pdf http:...
0
votes
0
answers
119
views
How to store and display image from Database using Servlet and EJB? [duplicate]
Can't find out how to add a profile picture to client when regstration in data base in web application using JSP, Registration Servlet and Entity Manager JPA for Mysql. For now I did this:
...
847
votes
15
answers
684k
views
Access restriction on class due to restriction on required library rt.jar?
I'm attempting to compile Java 1.4 code that was created by IBM's WSDL2Java on Java5 without recreating the stubs and saw this error in Eclipse.
I'm under the assumption that the stubs generated ...
172
votes
11
answers
167k
views
Read input stream twice
How do you read the same inputstream twice? Is it possible to copy it somehow?
I need to get a image from web, save it locally and then return the saved image. I just thought it would be faster to use ...
141
votes
8
answers
327k
views
Byte[] to InputStream or OutputStream
I have a blob column in my database table, for which I have to use byte[] in my Java program as a mapping and to use this data I have to convert it to InputStream or OutputStream. But I don't know ...
31
votes
6
answers
91k
views
FileUpload with JAX-RS
I try to do file upload from a JavaScript client to a JAX-RS Java server.
I use the following REST upload function on my server:
@POST
@Produces('application/json')
UploadDto upload(
@...
27
votes
12
answers
32k
views
Compress an InputStream with gzip
I would like to compress an input stream in java using Gzip compression.
Let's say we have an input stream (1GB of data..) not compressed. I want as a result a compressed inputstream from the source :...
32
votes
4
answers
45k
views
How to download s3 object directly into memory in java
Is it possible to download S3object in Java directly into memory and get it removed when i'm done with the task?
28
votes
4
answers
68k
views
Convert InputStream(Image) to ByteArrayInputStream
Not sure about how I am supposed to do this. Any help would be appreciated