ByteArrayInputStream is a Java and Android class implementing a stream that reads data from a byte array.
Questions tagged [bytearrayinputstream]
91 questions
29
votes
5 answers
Convert Contents Of A ByteArrayInputStream To String
I read this post but I am not following. I have seen this but have not seen a proper example of converting a ByteArrayInputStream to String using a ByteArrayOutputStream.
To retrieve the contents of a ByteArrayInputStream as a String, is using a…
Mushy
- 2,225
- 9
- 30
- 50
27
votes
5 answers
How to create ByteArrayInputStream from a file in Java?
I have a file that can be any thing like ZIP, RAR, txt, CSV, doc etc. I would like to create a ByteArrayInputStream from it.
I'm using it to upload a file to FTP through FTPClient from Apache Commons Net.
Does anybody know how to do it?
For…
itro
- 6,260
- 23
- 69
- 98
16
votes
4 answers
How do I take a ByteArrayInputStream and have its contents saved as a file on the filesystem
I have an image which is in the form of a ByteArrayInputStream. I want to take this and make it something that I can save to a location in my filesystem.
I've been going around in circles, could you please help me out.
Ankur
- 47,089
- 107
- 237
- 309
15
votes
2 answers
How to create a multipart zip file and read it back?
How would I properly zip bytes to a ByteArrayOutputStream and then read that using a ByteArrayInputStream? I have the following method:
private byte[] getZippedBytes(final String fileName, final byte[] input) throws Exception {
…
Benny
- 1,378
- 2
- 15
- 34
14
votes
3 answers
Why to use ByteArrayInputStream rather than byte[] in Java
As I understand ByteArrayInputStream is used to read byte[] data.
Why should I use it rather than simple byte[] (for example reading it from DB).
What is the different between them?
Sahar Menashe
- 1,637
- 1
- 15
- 16
10
votes
2 answers
Receive byte[] using ByteArrayInputStream from a socket
Here is the code but got error:
bin = new ByteArrayInputStream(socket.getInputStream());
Is it possible to receive byte[] using ByteArrayInputStream from a socket?
hkguile
- 3,721
- 13
- 57
- 118
8
votes
1 answer
LibGDX creating texture from base64 PNG ByteArrayInputStream
I just decided to make the change from Slick2D to LibGDX. However, for me to be able to port my game over to LibGDX I need help understanding how to create textures in LibGDX from my game data files.
My game data files are encrypted and the images…
Ike Yousuf
- 81
- 5
7
votes
3 answers
Byte array to buffered image conversion slow
I have a simple server-side code that receives a byte array representing an image in JPEG format and returns the dimensions of the image.
public String processImage(byte[] data) {
long startTime = System.currentTimeMillis();
…
baekacaek
- 1,467
- 2
- 21
- 42
7
votes
4 answers
What's the difference between InputStream and ByteArrayInputStream?
The following code is extracted from the java web start chapter of the core java volume 1.
ByteArrayOutputStream out = new ByteArrayOutputStream();
PrintStream printOut = new PrintStream(out);
printOut.print(panel.getText());
…
scobur
- 225
- 2
- 3
- 8
6
votes
1 answer
How can i convert ByteArrayInputStream to jpeg and display on android mobile?
1.i get the android camera data convert to bitmao
if (mBitmap == null) //create Bitmap image first time
{
Camera.Parameters params = camera.getParameters();
width_ima = params.getPreviewSize().width;
…
纯洁的坏蛋
- 179
- 1
- 12
5
votes
2 answers
Create an in-memory FileDescriptor
FileDescriptor API in Android says:
Instances of the file descriptor class serve as an opaque handle to
the underlying machine-specific structure representing an open file,
an open socket, or another source or sink of bytes.
I want to create a…
PC.
- 6,367
- 4
- 30
- 66
4
votes
2 answers
Should streams be closed after every use?
I am currently working on a UDP server for a game. In this server use a ByteArrayInputStream and a ObjectInputStream every tick to convert serialized bytes to objects. Is it more efficient to create one variable for the streams and close them once…
Maxwell
- 41
- 6
4
votes
1 answer
Is there a better way to grab a list of Avro records from an InputStream?
I have a ByteArrayInputStream that was serialized with a List which is an implementation of SpecificRecord. I could not find a way for Avro to know about the list that was serialized so I did a hackish way to loop through the…
Aaron Waner
- 41
- 5
4
votes
5 answers
Java BufferedReader.readLine() not waiting for EOL?
Sorry if I'm missing something obvious here...but please take a look at this code snippet:
String readString;
String writeString = "O hai world.";
BufferedReader br = new BufferedReader(
new InputStreamReader(
new…
jasterm007
- 143
- 2
- 8
3
votes
0 answers
Is there a way to read or see the files or information stored in RAM in a computer?
I'm working on a security project and I'm wondering how hard is it to read into the RAM memory of a computer.
For example, I have a Java program that reads an image into ByteArrayInputStream, how hard would it be for someone to see this file if I…
Maflores16
- 67
- 1
- 8