file-io

Formatting a text file, how to update the file after I finished parsing it?

How would I open a file, perform some regex on the file, and then save the file? I know I can open a file, read line by line, but how would I update the actual contents of a file and then save the file? ...

Wanted 'LibrarySystem.ctrlSeparator' file in C# .Net

I want this file ('LibrarySystem.ctrlSeparator') to run my project in C#. Can anyone tell me a solution to get this file. This file is needed for my library management project. ...

How to read till end of file in MATLAB?

I have a file a.txt: 03,17.406199 05,14.580129 07,13.904058 11,14.685388 15,14.062603 20,14.364573 25,18.035175 30,21.681789 50,22.662820 The number of rows in the file are not known. I want to read the file and store 3 5 7 11 15 20 30 50 in one array and the float values in another. How do I read in a file when the length of dat...

Reading values from file stream and storing them into a variable size array - OpenGL and C

Hi, I am trying to read the following file (The comments are not there in the original): Tetra.tri 4 4 // tot number of vertexes & tot number of triangles 0.693361 0.693361 0.693361 // vertex coordinates 0.693361 -0.693361 -0.693361 -0.693361 -0.693361 0.693361 -0.693361 0.693361 -0.693361 3 1 2 3 // triangles to display (the 3...

How do I check if a file exists? (Java on Windows)

How can I check whether a file exists, before openinging it for reading in Java? (equivalent of Perl's -e $filename). The only similar question on SO dealt with writing the file and was thus answered using FileWriter which is obviously not applicable here. If possible I'd prefer a real API call returning true/false as opposed to some...

Opening gzipped files for reading in C without creating temporary files

Hello, I have some gzipped files that I want to read in C via fopen and fscanf. Is there anyway to do this without having to gunzip the files to temporary files? Thanks. ...

Should I create a separate class for this?

My project contains a lot of classes, a bunch of which can be described by XML files. Don't worry, it's not the logic or implementation in XML. It's a game, and an example would be that a game tile can be defined in XML, the image file, animation frames, etc. I'm going to end up having a bunch of functions that look like this: public ...

BlackBerry - Location/directory on device to save file from application

My program saves a file on the device during runtime and reads/writes data from it during runtime. Currently it gets saved in the SDCard. I want to know if saving it in device flash memory would be better than removable media. Does device allows us to write something in its internal memory? Suggestions/Ideas? Thanks ...

Does File.AppendAllText close the file after the operation

Does the following close the file after the operation is performed? : System.IO.File.AppendAllText(path, text); A yes, no will suffice? ...

Remove files using a unix-like pattern

Hello, I would like to implement something equivalent to the unix command 'rm foo*' using Java. Obviously, I want it to be multi platform. I know that this can be done using the FilenameFilter class and File.delete() method, but I was wondering if I can perform this simple operation in a less verbose way. Thanks in advance. ...

Is pickle file of python cross-platform?

I have created a small python script of mine. I saved the pickle file on Linux and then used it on windows and then again used it back on Linux but now that file is not working on Linux but it is working perfectly on windows. Is is so that python is coss-platform but the pickle file is not. Is there any solution to this one??? ...

Read data into a float array in C

i am making a program where i need to load some floating point data of the format from a file 103.45 123.45 456.67 ...... i was wondering how to store these data directly into a array of floating point numbers using fread(). i guess it is not that hard using pointers but i am not so good with them. can anyone tell me how ...

appending in C failing, simply overwriting

Instead of appending "abc" (and thus eventually getting a file full of abcabcabc....), no matter how many times I run this, myfile only containst "abc".... how can I append? #include <stdio.h> #include <string.h> int main(){ char strng[10]; strcpy(strng,"abc"); FILE *my_file; my_file = fopen("myfile","a+"); if (my_f...

A floating point array in C

i am developing a code where i have to load floating point values stored in each line at a time in a text file...i loaded each of these data into a array of floats using fscanf()...however i found that the floating points were stored in a different way, example 407.18 was stored as 407.179993, 414.35 as 414.350006...now i am stuck becaus...

Is there any way to tell if the Windows Directory is writeable without actually writing to it to test?

I have some old vb6 code that checks to see if the Windows directory is writeable by WRITING to it then reading a value back. But... we have a virus scanner that's viewing that as suspicious behavior so I want to check it without touching it. Any Windows API calls for that? (Ideally for Win 98 and above) ...

Loading data from file in C

i am really struggling to load some numeric floating point data from a file into a C program...the file has floating point numbers with precision of 3 decimal points, each of which is in a single line...i wanted to load these values into an float array and then perform some calculations in it...however i tried loading it into an array of...

Problem writing array of doubles to a file

i have a really big array of numbers with double precision...i tried to write it into a file using fprintf()...i need to write these numbers one in each line so i have done something like this. if((fp2 = fopen("temp", "w")) == NULL) { perror("File cannot be opened"); exit(1); } for(int k = 0; k < j; k++ ) { fprintf(fp2, "%0.3lf\n", dif...

Python IO Gurus: what are the differences between these two methods?

I have two methods for writing binary files: the first works with data received by a server corresponding to a file upload (i.e., handling a form whose enctype="multipart/form-data"), and the second works with file data sent as email attachments (i.e., file data obtained by parsing an email message message body using get_payload()). The...

Can you keep a StreamReader from disposing the underlying stream?

Is there a way to do this: this.logFile = File.Open("what_r_u_doing.log", FileMode.OpenOrCreate, FileAccess.ReadWrite); using(var sr = new StreamReader(this.logFile)) { // Read the data in } // ... later on in the class ... this.logFile = File.Open("what_r_u_doing.log", FileMode.OpenOrCreate, FileAccess.ReadWrite); using(var sw ...

Read from same file (until EOF) using ifstream after file contents change

Requirement : I must read until EOF (16 bytes a time) from a particular file , and then say sleep for 5 seconds. Now, after 5 seconds, when I try to read from the file (whose contents would have been appended by that time), the intended design must be in such a way that it reads from the point where it left previou...