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
122
votes
14 answers

How to read a line from the console in C?

What is the simplest way to read a full line in a C console program The text entered might have a variable length and we can't make any assumption about its content.
pbreault
  • 14,176
  • 18
  • 45
  • 38
118
votes
3 answers

What does >& mean?

I was a little confused by this expression: gcc -c -g program.c >& compiler.txt I know &>filename will redirect both stdout and stderr to file filename. But in this case the ampersand is after the greater than sign. It looks like it's of the form…
contrapositive
  • 1,381
  • 2
  • 10
  • 11
117
votes
4 answers

Python multiprocessing safely writing to a file

I am trying to solve a big numerical problem which involves lots of subproblems, and I'm using Python's multiprocessing module (specifically Pool.map) to split up different independent subproblems onto different cores. Each subproblem involves…
Big Dogg
  • 2,564
  • 5
  • 21
  • 22
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
110
votes
9 answers

Guava equivalent for IOUtils.toString(InputStream)

Apache Commons IO has a nice convenience method IOUtils.toString() to read an InputStream to a String. Since I am trying to move away from Apache Commons and to Guava: is there an equivalent in Guava? I looked at all classes in the…
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
110
votes
4 answers

How to get resources directory path programmatically

I have the following directory layout: src main java resources sql (scripts for database) spring (configuration) webapp Within a ServletContextListener class, I want to access the files under the SQL directory and list them. Basically…
yamilmedina
  • 3,315
  • 2
  • 20
  • 28
109
votes
20 answers

hadoop No FileSystem for scheme: file

I am trying to run a simple NaiveBayesClassifer using hadoop, getting this error Exception in thread "main" java.io.IOException: No FileSystem for scheme: file at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:1375) at…
Mahender Singh
  • 1,393
  • 3
  • 17
  • 23
108
votes
13 answers

Read a small random sample from a big CSV file into a Pandas data frame

The CSV file that I want to read does not fit into main memory. How can I read a few (~10K) random lines of it and do some simple statistics on the selected data frame?
P.Escondido
  • 3,373
  • 6
  • 23
  • 29
108
votes
4 answers

Avoiding recursion when reading/writing a port synchronously?

All port operations in Rebol 3 are asynchronous. The only way I can find to do synchronous communication is calling wait. But the problem with calling wait in this case is that it will check events for all open ports (even if they are not in the…
Shixin Zeng
  • 1,458
  • 1
  • 10
  • 14
107
votes
1 answer

How to create in-memory file object

I want to make a in-memory file to use in pygame mixer. I mean something like http://www.pygame.org/docs/ref/music.html#pygame.mixer.music.load which says load() method supports file object. import requests from pygame import mixer r =…
FKLC
  • 1,672
  • 4
  • 14
  • 21
104
votes
8 answers

Printing Mongo query output to a file while in the mongo shell

2 days old with Mongo and I have a SQL background so bear with me. As with mysql, it is very convenient to be in the MySQL command line and output the results of a query to a file on the machine. I am trying to understand how I can do the same with…
Parijat Kalia
  • 4,929
  • 10
  • 50
  • 77
103
votes
6 answers

FileStream vs/differences StreamWriter?

What is difference between FileStream and StreamWriter in .NET? What context are you supposed to use it? What is their advantage and disadvantage? Is it possible to combine these two into one?
HelloWorld1
  • 13,688
  • 28
  • 82
  • 145
103
votes
2 answers

Buffered vs unbuffered IO

I learned that by default I/O in programs is buffered, i.e they are served from a temporary storage to the requesting program. I understand that buffering improves IO performance (maybe by reducing system calls). I have seen examples of disabling…
sud03r
  • 19,109
  • 16
  • 77
  • 96
102
votes
10 answers

reading v 7.3 mat file in python

I am trying to read a matlab file with the following code import scipy.io mat = scipy.io.loadmat('test.mat') and it gives me the following error raise NotImplementedError('Please use HDF reader for matlab v7.3 files') NotImplementedError: Please…
Shan
  • 18,563
  • 39
  • 97
  • 132
101
votes
6 answers

How to get File Created Date and Modified Date

I have an .NET EXE file . I want to find the file created date and modified date in C# application. Can do it through reflection or with IO stream?
griffithstratton
  • 1,021
  • 2
  • 7
  • 5