Questions tagged [io]

In computing, input/output, or I/O, refers to the communication between an information processing system (such as a computer), and the outside world, possibly a human, or another information processing system.

In computing, input/output, or I/O, refers to the communication between an information processing system (such as a computer), and the outside world, possibly a human, or another information processing system.

(Source: Wikipedia [Input/Output])


I/O includes tasks such as:

  • Reading and writing files ()
  • Interacting with a user through a command-line terminal session ( / / )
  • Connecting programs so that one sends its output to the next (s)
  • Sending data over a network in packets or as a data stream ()

For the Io language, see

17482 questions
64
votes
2 answers

How to write bytes to a file in Python 3 without knowing the encoding?

In Python 2.x with 'file-like' object: sys.stdout.write(bytes_) tempfile.TemporaryFile().write(bytes_) open('filename', 'wb').write(bytes_) StringIO().write(bytes_) How to do the same in Python 3? How to write equivalent of this Python 2.x…
jfs
  • 399,953
  • 195
  • 994
  • 1,670
63
votes
1 answer

Python slow read performance issue

Following an earlier thread I boiled down my problem to it's bare bones, in migrating from a Perl script to a Python one I found a huge performance issue with slurping files in Python. Running this on Ubuntu Server. NB: this is not a X vs. Y thread…
Simon
  • 1,613
  • 1
  • 12
  • 27
62
votes
3 answers

I/O completion port's advantages and disadvantages

Why do many people say I/O completion port is a fast and nice model? What are the I/O completion port's advantages and disadvantages? I want to know some points which make the I/O completion port faster than other approaches. If you can explain it…
Benjamin
  • 10,085
  • 19
  • 80
  • 130
62
votes
6 answers

InputStream vs InputStreamReader

What's the benefit of using InputStream over InputStreamReader, or vice versa. Here is an example of InputStream in action: InputStream input = new FileInputStream("c:\\data\\input-text.txt"); int data = input.read(); while(data != -1) { //do…
xil3
  • 16,305
  • 8
  • 63
  • 97
62
votes
2 answers

How to overwrite file via java nio writer?

I try files writer as follows: String content = "Test File Content"; I used as like : Files.write(path, content.getBytes(), StandardOpenOption.CREATE); If file is not create, file is created and content is written. But If file available , the…
cguzel
  • 1,673
  • 2
  • 19
  • 34
61
votes
2 answers

Will Go block the current thread when doing I/O inside a goroutine?

I am confused over how Go handles non-blocking I/O. Go's APIs look mostly synchronous to me, and when watching presentations on Go, it's not uncommon to hear comments like "and the call blocks". Is Go using blocking I/O when reading from files or…
Roger Johansson
  • 22,764
  • 18
  • 97
  • 193
61
votes
6 answers

Fastest save and load options for a numpy array

I have a script that generates two-dimensional numpy arrays with dtype=float and shape on the order of (1e3, 1e6). Right now I'm using np.save and np.load to perform IO operations with the arrays. However, these functions take several seconds for…
abcd
  • 10,215
  • 15
  • 51
  • 85
61
votes
8 answers

Read binary file into a struct

I'm trying to read binary data using C#. I have all the information about the layout of the data in the files I want to read. I'm able to read the data "chunk by chunk", i.e. getting the first 40 bytes of data converting it to a string, get the next…
Robert Höglund
  • 10,010
  • 13
  • 53
  • 70
60
votes
11 answers

Python - IOError: [Errno 13] Permission denied:

I'm getting IOError: [Errno 13] Permission denied and I don't know what is wrong wit this code. I'm trying to read a file given an absolute path (meaning only file.asm), and a relative path (meaning /.../file.asm), and I want the program to write…
Itzik984
  • 15,968
  • 28
  • 69
  • 107
59
votes
6 answers

Git log output to XML, JSON, or YAML?

This is a pretty simple question: as a Git newbie I was wondering if there's a way for me to output my git log to a file, preferably in some kind of serialized format like XML, JSON, or YAML. Any suggestions?
Andrew
  • 42,517
  • 51
  • 181
  • 281
59
votes
13 answers

Creating a directory in /sdcard fails

I have been trying to create a directory in /sdcard programmatically, but it's not working. The code below always outputs directory not created. boolean success = (new File("/sdcard/map")).mkdir(); if (!success) { Log.i("directory not…
sajjoo
  • 6,576
  • 20
  • 65
  • 86
59
votes
9 answers

How can I read user input in Rust?

I intend to make a tokenizer. I need to read every line the user types and stop reading once the user presses Ctrl + D. I searched around and only found one example on Rust IO which does not even compile. I looked at the io module's documentation…
Jimmy Lu
  • 4,810
  • 7
  • 25
  • 30
59
votes
2 answers

Blocking IO vs non-blocking IO; looking for good articles

Once upon a time I bumped into Introduction to Indy article and can't stop thinking about blocking vs non-blocking IO ever since then. Looking for some good articles describing what are pros and cons of blocking IO and non-blocking IO and how to…
Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
58
votes
5 answers

difference between flush and close function in case of filewriter in java

I need to know what is exact difference between flush and close function in Java? And When the data is dumped into a file during writing of file? Please provide one example
mum
  • 825
  • 2
  • 8
  • 11
58
votes
1 answer

Why is there no IO transformer in Haskell?

Every other monad comes with a transformer version, and from what I know the idea of a transformer is a generic extension of monads. Following how the other transformers are build, IOT would be something like newtype IOT m a = IOT { runIOT :: m (IO…
David
  • 8,275
  • 5
  • 26
  • 36