file-io

C++ detect space in text file

How can I go about detecting a space OR another specific character/symbol in one line of a file using the fstream library? For example, the text file would look like this: Dog Rover Cat Whiskers Pig Snort I need the first word to go into one variable, and the second word to go into another separate variable. This should happen for ev...

C++ remove trailing new line from text file

Is there a way in C++ to remove/trim a trailing new line from a text file? For example content content content content content content <- this line in the text file is empty and needs to go -> ...

How do I extract all the data from a bzip2 archive with C?

I have a concatenated file made up of some number of bzip2 archives. I also know the sizes of the individual bzip2 chunks in that file. I would like to decompress a bzip2 stream from an individual bzip2 data chunk, and write the output to standard output. First I use fseek to move the file cursor to the desired archive byte, and then ...

Fast data recording/logging on a separate thread in C#

Hello, We're developing an application which reads data from a number of external hardware devices continuously. The data rate is between 0.5MB - 10MB / sec, depending on the external hardware configuration. The reading of the external devices is currently being done on a BackgroundWorker. Trying to write the acquired data to disk with...

Whats wrong with the following code?

#include<stdio.h> #include<ctype.h> int main() { FILE *fpin = fopen("in.txt", "r"); fprintf(fpin, "hello, world!"); fclose (fpin); char c; fpin = fopen("in.txt", "r"); FILE *fpout = fopen("out.txt", "w"); while ((c = fgetc(fpin)) != EOF) { fputc (toupper(c), fpout); } fclose (fpout); fc...

[Java] Setting Path Directory on File Reader

Hey! Question: I'm workin with text files on Java. On Ubuntu 10. But, i'm having problems with path dir. Example: saveFile("textFile.txt","abc"); This abstract fuction basically put "abc" on "textFile.txt". I compile this file, and create a jar file (using NetBeans). When i run the app, and call saveFile("textFile.txt","abc"), text...

Write a text file using stream

reader = new InputStreamReader(MyClass.class.getResourceAsStream( "/apathdir/textFile.txt"), "UTF-8") Hi! I have this reader and, basically, i want to do a writer, this way, save this file on same path of the jar file, like: >ls >myJarFile.jar textFile.txt ...

Using "pathdir" on Java Applications

Hey guys, First, i'm using Ubuntu! :) I need some help here, I built a Java App, i want to set a default path tree, like this: > cd /anyDirectory/meuRestaurante > ls bin/ data/ > cd bin > ls meuRestaurante.jar > cd .. > cd data > ls Cartoes.txt Clientes.txt I want that my Java App save these txt's files on /data directory, while is o...

What is the Python equivalent of Unix 'touch'?

I'm writing a function and I want it to touch a file so that I can write to that file. If the file doesn't exist, I will get an error. How can I say that? ...

Writing empty string to textfile in Python

Quite embarassing issue, though i come from web development and rarely have to deal with files i/o. I wrote a simple config updater for use on my shared hosting. It scans the directory for subdirectories, and then writes config lines to a file - one line for each subdirectory. The problem is, when it detects there are config lines but n...

Question on how to develop and then parse a data structure

I'm designing a weather program where I need to keep track of certain things and allow the user to add data which will be saved and subsequently read later. My fields are City State Zip Metar I might have more I want to do with this configuration file later, so I would like it to have something like this: [LOCATIONS] Phoenix:AZ:85001:...

how to use tempfile.NamedTemporaryFile() in python

Hi, I want to use tempfile.NamedTemporaryFile() to write some contents into it and then open that file. I have written following code: tf = tempfile.NamedTemporaryFile() tfName = tf.name tf.seek(0) tf.write(contents) tf.flush() but I am unable to open this file and see its contents in notepad or similar application. Is there any way ...

New FileStream already closed/disposed?

I open a FileStream with FileMode.Open and FileAccess.Read. Shortly after that I call a function to handle the file's contents. I use Invoke to make the call because the call comes from a Thread and the function has to put the results on a Form. The function accepts any kind of Stream (I call it with MemoryStreams too without a problem) ...

C# I/O - Difference between System.IO.File and StreamWriter/StreamReader

Assuming I am interested only in dealing with text files, what specific advantages or disadvantages does System.IO.File methods provide when compared to StreamWriter? Are there any performance factors involved? What is the basic difference, and which of these should be used in what cases? One more question, If i want to read the conten...

[PHP] Small help saving to txt file

Hello there so I just setup this basic poll, I inspired myself from something I found out there, and it's just a basic ajax poll that waves the results in a text file. Although I was wondering, since I do not want the user to simply mass-click to advantage / disadvantage the results, i thought about adding a new text file that could sim...

Java: File i/o tuning

I attempted to create a sort-of file generator which spits out hardcoded messages to a file with slight alterations to some of the strings based on user input. Since I'm utilizaing polymorphism, I have multiple files and interfaces. I'm finding myself passing a file parameters more times than one and is starting to rethink the way I've...

Jython: subprocess.Popen runs out of file descriptors

I'm using the Jython 2.51 implementation of Python to write a script that repeatedly invokes another process via subprocess.Popen and uses PIPE to pipe stdout and stderr to the parent process and stdin to the child process. After several hundred loop iterations, I seem to run out of file descriptors. The Python subprocess documentati...

How to create appending writeStream in Node.js

Current documentation here doesn't seem to mention any parameters governing the stream's behaviour with regards to whether file is re-created every time or just gets data appended. Is there a way to create a writeStream which appends the data? ...

Javascript saving xml using Ruby on Rails

Hello, First, what I am trying to do is: I am trying to create a browser application that works on clientside. The basic idea is the user uploads a xml file into javascript. Javascript does calculations on this data and displays results onto the browser. The user is able to interactively edit the result (something like an image/video) ...

How can I efficiently read words from a 10 G file and put them in order of their frequency?

I have to read words from a 10 G file and put them in a sorted manner of their frequency, how can I achieve this in most efficient way? ...