Questions tagged [buffer]

A buffer is an area of memory set aside for temporary storage of data while it is being moved from one place to another. This is typically done to speed up processes with significant latency, such as writing to a disk, printer or other physical device. The output is ready to be sent to the device before the device is ready to accept it, so it is moved to the buffer so that the sending program does not have to continue waiting.

A may be used when moving data between processes within a computer. This is comparable to buffers in telecommunication. Buffers can be implemented in a fixed memory location in hardware—or by using a virtual data buffer in software, pointing at a location in the physical memory. In all cases, the data stored in a data buffer are stored on a physical storage medium. A majority of buffers are implemented in software, which typically use the faster RAM to store temporary data, due to the much faster access time compared with hard disk drives. Buffers are typically used when there is a difference between the rate at which data is received and the rate at which it can be processed, or in the case that these rates are variable, for example in a printer spooler or in online video streaming.


References

7035 questions
139
votes
10 answers

Clearing a string buffer/builder after loop

How do you clear the string buffer in Java after a loop so the next iteration uses a clear string buffer?
waterfallrain
  • 1,399
  • 2
  • 8
  • 3
132
votes
3 answers

What does flushing the buffer mean?

I am learning C++ and I found something that I can't understand: Output buffers can be explicitly flushed to force the buffer to be written. By default, reading cin flushes cout; cout is also flushed when the program ends normally. So flushing…
Mohamed Ahmed Nabil
  • 3,949
  • 8
  • 36
  • 49
127
votes
2 answers

How to display nodejs raw Buffer data as Hex string

The following code uses SerialPort module to listen to data from a bluetooth connection. I am expecting to see a stream of data in Hexadecimal format printed in console. But the console just shows some weird simbols. I want to know how can I decode…
GingerJim
  • 3,737
  • 6
  • 26
  • 36
125
votes
6 answers

What exactly is the point of memoryview in Python?

Checking the documentation on memoryview: memoryview objects allow Python code to access the internal data of an object that supports the buffer protocol without copying. class memoryview(obj) Create a memoryview that references obj. obj must…
Basel Shishani
  • 7,735
  • 6
  • 50
  • 67
124
votes
5 answers

Refresh all files in buffer from disk in vim

The command to refresh a file from version on disk is :e! How can I do the same for all files in the buffer? Background: I need that because I am using git with multiple branches with one vim open that contains a buffer. When I checkout a branch, I…
odwl
  • 2,095
  • 2
  • 17
  • 15
123
votes
4 answers

Diff two tabs in Vim

Scenario: I have opened Vim and pasted some text. I open a second tab with :tabe and paste some other text in there. Goal: I would like a third tab with a output equivalent to writing both texts to files and opening them with vimdiff. The closest I…
davetapley
  • 17,000
  • 12
  • 60
  • 86
122
votes
10 answers

Replace word with contents of paste buffer?

I need to do a bunch of word replacements in a file and want to do it with a vi command, not an EX command such as :%s///g. I know that this is the typical way one replaces the word at the current cursor position: cw but is there a way to…
plong
  • 1,723
  • 3
  • 14
  • 14
114
votes
19 answers

How can I clear an input buffer in C?

I have the following program: int main(int argc, char *argv[]) { char ch1, ch2; printf("Input the first character:"); // Line 1 scanf("%c", &ch1); printf("Input the second character:"); // Line 2 ch2 = getchar(); …
ipkiss
  • 13,311
  • 33
  • 88
  • 123
106
votes
2 answers

Intellij IDEA with ideavim. Cannot copy text from another source

I tried to copy text from IDEA with ideavim plugin, using default vim keybindings (y). But this text isn't copied in global buffer and i can paste it only in IDEA. How can I use copied piece of text in browser, for example?
Supo
  • 1,135
  • 3
  • 8
  • 10
102
votes
5 answers

What exactly does "Stream" and "Buffer" mean in Java I/O?

I just learned about input/output using BufferedReader. I wanted to know what exactly are the meanings of the term Stream and Buffer? Also what does this line of code serves us: BufferedReader br=new BufferedReader(new…
user122345656
  • 1,523
  • 5
  • 15
  • 20
102
votes
4 answers

How to append binary data to a buffer in node.js

I have a buffer with some binary data: var b = new Buffer ([0x00, 0x01, 0x02]); and I want to append 0x03. How can I append more binary data? I'm searching in the documentation but for appending data it must be a string, if not, an error occurs…
Gabriel Llamas
  • 18,244
  • 26
  • 87
  • 112
98
votes
16 answers

How do you prefer to switch between buffers in Vim?

I've tried MiniBufExplorer, but I usually end up with several windows showing it or close it altogether. What I'd like is something like LustyJuggler with incremental search, the way I switch between buffers in Emacs. Surely there is a script like…
Alexey Romanov
  • 167,066
  • 35
  • 309
  • 487
90
votes
9 answers

Ring Buffer in Java

I have a streaming time series, of which I am interested in keeping the last 4 elements, which means I want to be able to pop the first, and add to the end. Essentially what I need is a ring buffer. Which Java Collection is the best for this?…
Truba
  • 909
  • 1
  • 7
  • 3
89
votes
3 answers

When to use byte array & when byte buffer?

What is the difference between a byte array & byte buffer ? Also, in what situations should one be preferred over the other? [my usecase is for a web application being developed in java].
Rajat Gupta
  • 25,853
  • 63
  • 179
  • 294
89
votes
6 answers

Why do I need std::get_temporary_buffer?

For what purpose I should use std::get_temporary_buffer? Standard says the following: Obtains a pointer to storage sufficient to store up to n adjacent T objects. I thought that the buffer will be allocated on the stack, but that is not true.…
Kirill V. Lyadvinsky
  • 97,037
  • 24
  • 136
  • 212