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 display, an information storage system, or another information processing system).

Filter by
Sorted by
Tagged with
2
votes
3answers
494 views

Path validation helper in a 'path input box'

I have a helper extension method that I use for path string validation. It looks as below. It's purpose is to work with network paths as well, so in case a network resource is not available, I do not ...
6
votes
3answers
562 views

Simple input/output practice

This code is just some exercise code printing questions and waiting for answers. It is working perfectly well as far as I can tell. I would like to know if this code could be considered acceptable or ...
4
votes
1answer
714 views

Method to read the number of lines in a web page

Needing a way to read the number of lines on a web page for the purpose of a progress bar the following method is created: ...
7
votes
2answers
415 views

Very basic Java file reader/writer

I started learning the Java language about 10 days ago, reading Introduction to Programming Using Java by David J. Eck. I've made it halfway through chapter six in about 9 days. I realized I was ...
4
votes
2answers
65 views

Compare Two Files

One of the K&R exercises is to write a small piece of software to compare two files and print the first line in which they differ. Here is my attempt: ...
4
votes
1answer
67 views

Word Counter Project

I recently read K&R The C Programming Language and wanted to write a small program to count the occurrence of each word in the input (std-input - I piped a file with all shakespeare pieces in ...
3
votes
2answers
165 views

FIFO getch/ungetch Functions

I'm currently working myself through K&R and just read about implementing getch() and ungetch(). In K&R these ...
2
votes
1answer
295 views

Reading a file in Python

I currently have this code to read lines from a file ...
4
votes
1answer
5k views

Read text file filled with numbers and tranfer to an array

This is my ProcessDataFileParallel.Java file. I'm taking numbers from a .txt file and putting it into an array in Java. While it works, I would like to improve the code and possibly change some ...
4
votes
1answer
414 views

Giveth me thy easier user input in C++ - follow up

I've decided to take some of the many suggestions for improvement on my previous question, Easier user input in C++, and actually get it to work as expected. This time around, a few things are ...
6
votes
3answers
12k views

Writing and reading code from a text file

Using file stream object, write a program to read an external text file ("myCourse.txt") which contains all the course name and numbers you are taking this semester, and to generate an analysis (total ...
3
votes
2answers
3k views

Getting a hash string for a very large file

After reading about large files and memory problems, I'm suspecting that my code below may be inefficient because it reads the entire files into memory before applying the hash algorithm. Is there a ...
4
votes
2answers
1k views

Speeding Up BufferedWriter

Are there any possible speed improvements I can make to the following method. It takes a JDBC ResultSet and breaks it into several CSV files: ...
1
vote
1answer
89 views

Searching and replacing text

Simple Playlist Modifier This program is a search and replace program for text based files. The main goal of the program is to replace directory paths to music files. The idea is to have the program ...
38
votes
5answers
4k views

Easier user input in C++

A more proper version of this utility can be found at the following link here: Giveth me thy easier user input in C++ - follow up. I've always been a little bothered by the fact, that in order to get ...
1
vote
1answer
78 views

Downloading and reading data in go

I am trying to experiment with golang. This code spins off two Go routines: one to download data and another to read from the body. Both go threads are synced by the data channel. I have two ...
5
votes
1answer
2k views

Using a mutex to read from a file [closed]

I am new to C and I am trying to implement a mutex. The idea of the program is: main() will create three threads. Each thread will read one character each from ...
4
votes
1answer
1k views

OutputStream class for use with subprocess.Popen

I've recently been writing an application which does a lot of work with the output of commands. To call the commands I've been using the subprocess module, and originally, was using ...
4
votes
3answers
6k views

Read file into list when class is instantiated in Python 2.7

I would like to read a file into a list when I create the class below. Once the list is ready, I would like to access it outside the class in order to process more code based on the list which now ...
3
votes
2answers
1k views

C - K&R getint() variation

I'm currently learning C with "The C Programming Language" by K&R. At the moment I'm at the chapter about pointers (since I come from Java, they are new to me). In the book is an example code for ...
5
votes
2answers
597 views

Print output one word per line - K&R Exercise 1-12

When writing this code I found myself getting more and more complex. When I got to the solution I trimmed the excess parts I'd thought I needed from before, but didn't actually need. The example of wc....
24
votes
4answers
3k views

“ONCE”, “UPON”, “A”, “TIME”

I'm working on a small program to perform various tasks on text content, primarily at the word level. I wrote these methods as ways to help prepare the raw text file into something more malleable, ...
10
votes
1answer
380 views

cat program in Prolog

In order to learn Prolog, I have implemented the cat command in Prolog. I want to know if the code is idiomatic and what could be improved. File ...
4
votes
2answers
204 views

Property file loader

I have the following code: ...
8
votes
1answer
130 views

cat program in Go

In order to learn Go, I've implemented the cat program in Go. I want to know if the code is idiomatic and what could be improved. ...
11
votes
1answer
1k views

Scanner in Scala

I wanted to implement Java's Scanner in Scala. The goal for this class is to: Implement a Scala collection interface (probably ...
3
votes
1answer
96 views

Pass the password back

This code simply receives a very basic 'password' (numbers, letters, nothing fancy). After you press enter, it will display it back. The only special key I'm handling is backspace (code ...
3
votes
2answers
10k views

Non-blocking Unix domain socket

I've developed quickly two kinds of socket use: the first with blocking mode and the second with non-blocking mode. The sockets are Unix domain sockets. My problem is that the kernel consume a huge ...
2
votes
1answer
674 views

Context managers that also deal with sys.stdin and sys.stdout

It's pretty typical for Linux command-line utilities that deal with files to accept either a file as input, or stdin. It's also pretty common for them to be able to ...
6
votes
1answer
104 views

Input processing/state machine function

I'm making a Mario clone in pygame and I have just wrote a function proccesses inputs and acts as a state machine for Mario. Everything is working just as I want it, but I was wondering if you can ...
7
votes
2answers
1k views

TCP Tunnel in C

I'm completely aware that I'm not using NIO, but this is my first polished C project. All criticism is welcome, if I'm doing something wrong, I want to nip it in the bud before I'm used to it. ...
5
votes
2answers
18k views

Returning the length of the File in B/KB/MB

The method length() in File returns the length of a file in Bytes, this code transforms that into b/kb/mb as can be seen in the ...
7
votes
2answers
224 views

Complete “Is it simple or is it hard?” challenge from Code Golf

Having written C# for half a year now, I decided to take on a fairly complex first challenge for C++: the Is it simple or it is hard? challenge from Code Golf Stack Exchange. (This is only practice, ...
7
votes
1answer
173 views

Adding support to Busybox vi for reading file from stdin

I am writing a patch for Busybox's implementation of vi, the classical command line code editor and predecessor of vim. It can ...
8
votes
2answers
5k views

Reading input from console in F# (as a sequence of lines)

Consuming input line-by-line until the end is often useful. In C# I would write the following loop while ((line = Console.ReadLine()) != null) {. I wanted to do ...
4
votes
2answers
382 views

Testing third parth software performance [closed]

This is a simple example of script to run the test write/read performance of third party software of the drive in Windows environment. Please let me know if you find any place can be better improved, ...
3
votes
1answer
187 views

Reimplementing numpy.genfromtxt in Fortran for Python

I've found that the function genfromtxt from numpy in Python is very slow. Therefore I decided to wrap a subroutine with f2py to read my data. The data is a matrix....
3
votes
1answer
1k views

Reading from file, changing characters and writing to another file with FileInput/OutputStream

I'm a freshwoman at Systems Information, new to Java and programming and was assigned this task by my professor. My job is to read characters from a text file (file details in the bottom), recognizing ...
3
votes
5answers
2k views

10 green bottles assignment

This code was for a university assignment. It's well passed now so don't be scared of giving me false grades, for example. I was wondering what could be done better, or bits of code that are horribly ...
3
votes
1answer
566 views

NIO2 and ByteBuffer use for reading variable length messages

I am reading variable length messages where each message is an int + msg bytes. Messages could be any size. Right now my strategy is to have a direct buffer that reads from the socket, which then ...
5
votes
1answer
75 views

Event driven timed I/O

The following code is used to access a shield which converts settings written over I2C to Servo output. I make use of the MRAA library since that's the default supported by my hardware. To prevent ...
3
votes
1answer
2k views

Loop for downloading file from the server (in client-server application)

In my client server application, client sends some commands and the server gives the results back. Now my special concern is about the looping for downloading file from the server class, that is ...
7
votes
1answer
109 views

Temporary file utility class in Python

I decided to write a tiny class to automatically write and delete a file given filename and content. It is intended to make testing IO less verbose. I include a small example usage. ...
8
votes
4answers
1k views

getline substitute that will enforce 'n' as limit of characters read

Following from a discussion with others on StackOverflow concerning the issue with getline not limiting input and happily reallocating until enough space for a ...
1
vote
1answer
329 views

Project Euler 22: Names Scores — With flowchart

Full text of the problem Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into alphabetical order. Then ...
4
votes
2answers
102 views

Size improvements for cat reimplementation

I have written a reimplementation of cat that will be compliant with most scripts, and that is as small and fast as possible. Can anybody suggest some size improvements for it? ...
5
votes
2answers
8k views

IO and Scanner exception handling

I have created a sample file reading program as an exercise while learning how to implement good exception handling. I want to ask: is this a good approach or is there some other solution that I am ...
5
votes
2answers
5k views

Python wrapper for Windows pipes

This is done in the style of a single class, that should work like any other io-based object in Python. Help is much appreciated with anything regarding performance, documentation, or anything else. <...
11
votes
2answers
30k views

Merging multiple JSON files using Python

I have multiple (1000+) JSON files each of which contain a JSON array. I want to merge all these files into a single file. I came up with the following, which reads each of those files and creates a ...
1
vote
1answer
130 views

Calculates and Generates student report card (Part 2)

I've updated my code according to some tips from a previous post and would like to post the new code for review. ...