I want to implement GET api that returns ZIP file. I defined api using openapi As far as I understand my api should return byte[], so my controller looks like below Is it ok to return byte[] or it should be some stream, end user will get the zip? Implementation. I have map of objects that I am parsing using
Tag: inputstream
InputStream never gets EOF
Before anything, allow me to show you my client code: once connected to the actual socket, the client sends out some authentication data, but doesn’t recieve any data, now, it waits to recieve data from the server, and when it does, it processes it fine etc, except, when I stop the server (literally shutting down the program), nothing happens, when
Using Streams and StreamSupplier: forEach closes StreamSupplier instead of instance of stream
I am making a obj file loader for an engine that I’m writing and I am trying to use Streams to load vertex index, uvcoord, and normals from this file. The way I intended to do this was to create a new stream from a stream supplier for each type I want to load. Right now I am just trying
Java InputStream wrapper which limits the nuber of read bytes
We need to have a process “peek” into the incoming InputStream and using a JSON streaming parser and ensure then no more then XXX bytes are read (i.e. we NEVER want to read past byte XX). …
Can you access files on the remote FTP server with RandomAccessFile?
I’m trying to read the file on the FTP remote-server using Apache Commons Net library. retrieveFileStream returns InputStream and put it in BufferedReader. But, I want to use RandomAccessFile (to use the seek() method). I want to get Inputstream as a RandomAccessFile. Is it possible? Answer If you want to starting reading the remote file from a certain offset, use
The Properties.load would close the InputStream?
I saw this example, and I didn’t see the close() method invoked on the InputStream, so would prop.load() close the stream automatically? Or is there a bug in the example? Answer The Stream is not closed after Properties.load () The above code returns “-1” so the stream is not closed. Otherwise it should have thrown java.io.IOException: Stream Closed
OpenCSV Avoid using FileWriter and return InputStream
I am using OpenCsv and the new CSVWriter() method takes a Writer as an argument. What I am trying to achieve is that to avoid writing to the file system and instead return an InputStream. I am not sure how to go about this. Not very familiar with Streams also I am using JAVA 7. Is it possible that I
Java copy part of InputStream to OutputStream
I have a file with 3236000 bytes and I want to read 2936000 from start and write to an OutputStream I can read and write byte by byte, but it’s to slow (i think) from buffered reading How can do I copy it? Answer should work for you.
BufferInputStream vs ByteArrayInputStream
Here are three ways to read an entire file into memory before processing it: Approach A: Approach B: Approach C: Why would I prefer one approach over another? Are there any specific use-cases that call for one approach over another? Why not use a fixed-length byte[] instead? Answer Unless you need anything special in terms of capabilities (e.g. random access),
How to read write this in utf-8?
I was getting an error io.MalformedByteSequenceException: Invalid byte 2 of 2-byte UTF-8 sequence The solution is to read and write file in UTF-8. My code is: I’m reading a url and writing it to a file DirectionResponse.xml. Then reading DirectionResponse.xml and writing the same as *ppre_DirecionResponse.xml* for processing. How do I change this so that reading and writing is done