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).
4
votes
1answer
26 views
Reading entire contents of file at a given java.no.file.Path into a String
What I'm wanting to do is create a String readFile(Path filePath, Charset encoding) method, that returns the entire contents of a given file.
I'm wanting the ...
8
votes
4answers
869 views
Creating a unique file name in C#
I find that I am often writing files where the names either:
Need to be incremented (rather than overwriting a file that already exists in the directory with the same name)
Need to be timestamped
...
3
votes
1answer
30 views
Memory mapped classpath HttpServlet
I have a single page application where the resources sit on the classpath. Any request for a resource that doesn't exist should redirect to the index.html page. ...
1
vote
0answers
27 views
Termios/Xterm line editor for APL interpreter
As an interesting sub-part of an interpreter -- just the Read part of the REPL -- I present my raw-mode line-oriented editor that I intend to use for my APL interpreter. It defines a large ...
8
votes
6answers
427 views
K&R 1-23 Remove all C comments
From K&R exercise 1-23,
Write a program to remove all comments from a C program. Don't forget
to handle quoted strings and character constants properly. C comments
don't nest.
My ...
15
votes
2answers
314 views
K&R 1-21 write an “entab” program
From K&R exercise 1-21,
Write a program entab that replaces strings of blanks by the minimum
number of tabs and blanks to achieve the same spacing. Use the same
tab stops as for detab. ...
16
votes
3answers
529 views
“Welcome to Buzzway Subs!”
There were a few recent questions which had a challenge like this:
The subway shop provides catering for meetings and other events. All
sandwich platters are $40 each. Cookie platters are $20 ...
2
votes
2answers
28 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
185 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
52 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
96 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
44 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
42 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 ...
2
votes
2answers
57 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
64 views
4
votes
1answer
124 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
93 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 ...
0
votes
1answer
62 views
Writing to a file in a multithreading application [closed]
This piece of code writes to a file and is used by multiple thread workers at the same time. From my observations, this is the slowest part in my whole application since threads have to wait for their ...
5
votes
3answers
224 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 ...
3
votes
2answers
44 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
41 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
29 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 ...
29
votes
5answers
2k 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 ...
0
votes
0answers
28 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
123 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
37 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 ...
2
votes
3answers
105 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
98 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
244 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 ...
21
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, ...
9
votes
1answer
102 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
62 views
8
votes
1answer
101 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.
...
10
votes
1answer
196 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
78 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 ...
1
vote
1answer
386 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
51 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
54 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
277 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.
...
3
votes
2answers
204 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
192 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
79 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 ...
5
votes
2answers
220 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 ...
3
votes
1answer
89 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 ...
3
votes
1answer
133 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
830 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
138 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 ...
4
votes
1answer
58 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
123 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 ...
6
votes
1answer
67 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.
...