Questions tagged [bufferedinputstream]

An abstract mechanism for reading a data stream into a buffer, for improved reading performance

An BufferedInputStream is a wrapper around an InputStream, whereby the data being read is buffered locally. Buffering can be either fully-buffered or partially-buffered. Fully-buffered is where the entire contents of the InputStream is held locally in a variable. Partially-buffered is where a small portion of the stream data is held in a local variable, and as you read data from the buffer, those bytes are replaced with the next X bytes from the stream - ie the buffer overwrites itself as the data is consumed from it.

An InputStream is usually buffered to improve performance, as it allows data to be read from a network of file in large efficient chunks, rather than a number of smaller reads. This removes the overhead and performance impact of the multiple small reads. The downside, however, is that the buffer consumes some memory and has some CPU impact, but these downsides are usually very tiny, and are far outweighed by the benefits of buffering.

291 questions
0
votes
1 answer

Getting bytes from InputStream to fixed length message

I read a lot methods and my head now is kind of overflow with different methods and i can't do what i want. From arduino i am sending fixed 8 byte message. Due to baud rate, HW problems or what ever i get the message separated in random sizes (for…
Martynas
  • 627
  • 2
  • 8
  • 28
0
votes
0 answers

Working with ObjectOutputStream and ObjectInputStream

Assume these: ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(remote.getOutputStream())); ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(remote.getInputStream())); After sending the "initiate…
0
votes
1 answer

Why if we want to zip a file in java we use BufferedInputStream rather than BufferedReader?

Why if we want to zip a file in java we always use FileInputStream and BufferedInputStream rather than BufferedReader and FileReader?
0
votes
1 answer

how to tune BufferedInputStream read()?

I am reading a BLOB column from a Oracle database, then writing it to a file as follows: public static int execute(String filename, BLOB blob) { int success = 1; try { File blobFile = new File(filename); …
technomax
  • 1
  • 1
0
votes
1 answer

What should i use InputStream or FileInputStream or BufferedInputStream?

I am downloading few pdf and video file from the server and for that I am using InputStream to collect response but I want to know that which is better for my purpose InputStream or FileInputStream or BufferedInputStream ? URL u = new…
Harry Mad
  • 488
  • 5
  • 17
0
votes
2 answers

The off parameter in BufferedInputStream.read(byte[] b, int off, int len)

The javadoc says the following. Parameters: b - destination buffer. off - offset at which to start storing bytes. len - maximum number of bytes to read. I would like to confirm my understanding of the "offset at which to start storing…
damat-perdigannat
  • 5,780
  • 1
  • 17
  • 33
0
votes
2 answers

Reading in files from array of files

I'm new to Java and am attempting to read in files from java, but I can't seem to figure out why this is happening. I'm getting IOExceptions and errors when I'm trying to read in the files. I just don't like how BufferedReader handles reading in…
user2069106
0
votes
1 answer

How do I receive byte array sent from a server and read 4 single bytes at a time

I need to receive 320 bytes of data from a server which consist of 80 4 byte int fields. How do I receive them in bytes of 4 and display their respective int values? Thanks. Not sure if this is right for the receiving part: //for reading the data…
k80sg
  • 1
0
votes
2 answers

Arithmetic error : / 0

I can't see what I'm doing wrong I'm new to processing and keeps giving me this error. It says this is the error code: int sampleCount = (int) ((byteCount - 36) / (bitDepth * channels)); this is the full class it's from : public…
0
votes
0 answers

android, Read content of 100-300 files from FTP folder... Hangs

I am using RetrieveFilestream method with BufferedInputStream in a for loop. I am closing all streams after processing each file and also adding ftp complete pending command. Every thing works as expected in my test environment with few files. But…
0
votes
2 answers

ArrayIndexOutOfBoundsException while reading data from file android

I am uploading video using multipartentity in chunks, to upload I am reading data from file. In the first loop I am able to read data, but in the next loop it is getting ArrayIndexOutOfBoundsException Exception : >…
0
votes
2 answers

Loop Statement For BufferedReader Is Not Working

I seem to be overlooking something quite obvious with my loop, but in its present state it is not posting the content of the eula text file to the alert dialog. Anyone see anything I am overlooking? There are 21 lines in the text file.…
user3391426
  • 433
  • 1
  • 5
  • 17
0
votes
1 answer

Generic solution to storing unknown size of data and performance

I have a text file with numbers, letters, special characters, and symbols. There are some lines where I want to insert an RLE unicode control character at the beginning/middle/end of the line. First I needed to find out how to catch and represent…
0
votes
3 answers

Convert Object to BuffredInputStream in JAVA

Hi i used the below code to convert my object into Input stream. But I actually wanted to convert my object into BufferedInputStream. What changes should i make to my code ? ByteArrayOutputStream baos = new ByteArrayOutputStream(); …
user1503007
  • 1
  • 1
  • 1
  • 1
0
votes
2 answers

Creating large file with BufferedOutputStream takes a long time

I have a file which is comprised of one serialized String object written to the start of the file followed by the raw bytes of the file I am attempting to extract. Here is my code: FileInputStream fileInputStream = new…
Danny Rancher
  • 1,923
  • 3
  • 24
  • 43