file-io

Something like print END << END; in C++?

Is there anyway to do something like PHP's print << END yadayadayada END; in C++? (multi-line, unescaped, easy-to-cut-and-paste stream insertion) ...

python adding gibberish when reading from a .rtf file?

I have a .rtf file that contains nothing but an integer, say 15. I wish to read this integer in through python and manipulate that integer in some way. However, it seems that python is reading in much of the metadata associated with .rtf files. Why is that? How can I avoid it? For example, trying to read in this file, I get.. {\...

How to write logs to files of size 64KB in C++/VC++?

How to write logs to files of size 64KB(to allow notepad to read).Once the file has reached 64KB it should go head and create another , another ...... File names can be automatically generated. I tried the following code static int iCounter=1; CString temp; static CStdioFile f(L"c:\\Log1.txt", CFile::modeWrite | CFile::modeRead |...

how to create a file in Java only if one doesn't already exist?

I'm trying to implement the following operation in Java and am not sure how: /* * write data (Data is defined in my package) * to a file only if it does not exist, return success */ boolean writeData(File f, Data d) { FileOutputStream fos = null; try { fos = atomicCreateFile(f); if (fos != null) {...

Is opening a file stream a costly operation

Is opening a file stream a costly operation I'd like to provide a lazy loading functionality in a class that reads a structured file. Every element of the file has a header and a payload. the idea is to load only the headers from the file and access the payload data only when the relevent field is accessed a prototype of the class wo...

File operations

Hi I wanted move the file from one folder to another(target) folder.If the same file is already exist in target folder i wants to rename .how to implement in C#. Thanks in advance Sekar ...

How to read certain text containing line and then append this text to those of multiple files in which this text line is absent?

I have multiple files with *.mol extensions. In the last line in some of them there is "M END" text. I need a program reading all these files, searching for "M END" line in that files and write this "M END" to those of them which have not "M END" line at the end of file. I wrote the following C# code, but it doesn't work. using Syst...

How to send a file to the brower using ASP.NET MVC controller action?

I have an application where I allow my users to upload a file of any type. I save this in the file system on the server. The applciation will only be accessed by two users , so I don't need to worry about uploading any dodgy files. How do I allow my user to press a button on an MVC form to request the file be sent back via the browser...

HD Regular Expression Search

I am working on a project for my computer security class and I have a couple questions. I had an idea to write a program that would search the whole hard drive looking for email addresses. I am just looking for addresses stored in plain text since it would be hard to find anything otherwise. I figured the best way to find addresses would...

MSVC _open/_close/etc

Why are the API's _open, _close, and other standard file i/o functions prefixed with an underscore? Aren't these part of some standard? ...

Does groovy have an easy way to get a filename without the extension?

Say I have something like this: new File("test").eachFile() { file-> println file.getName() } This prints the full filename of every file in the test directory. Is there a Groovy way to get the filename without any extension? (Or am I back in regex land?) ...

Why does ofstream sometimes create files but can't write to them?

I'm trying to use the ofstream class to write some stuff to a file, but all that happens is that the file gets created, and then nothing. I have some simply code here: #include <iostream> #include <fstream> #include <cstring> #include <cerrno> #include <time.h> using namespace std; int main(int argc, char* argv[]) { ofstream file; ...

Transactional File Access and Caching in JBoss AS 5

We need to locally store a cache on a File System through JBoss 5. The files we need to store are big (~50 Mbyte) and there are many consumer (through WS on JBoss) that read these files and one producer (JBoss Biz Logic) that creates the last one. Because there are concurrent read and write problems, I would like to know if there is a ...

File locking (read/write) in Java

I'm writing something to handle concurrent read/write requests to a database file. ReentrantReadWriteLock looks like a good match. If all threads access a shared RandomAccessFile object, do I need to worry about the file pointer with concurrent readers? Consider this example: import java.io.FileNotFoundException; import java.io.IOExc...

Why is this C code buggy?

On another question, Jerry Coffin pointed out the following: It's (probably) not really related to your question, but while (!feof(fileptr)){ is pretty much a guaranteed bug. I figured I would start a separate question since that comment is somewhat off-topic. Could someone explain this to me? This was the first program I've writ...

how to use a supplied username and password to read a file in Java

I need to read a bunch of binary files from a Java script running on Windows. However, the folder that the files are in has limited permissions. I (i.e. my Windows username) have permissions to read them, but the user that Java runs as (this is part of a web application) does not. If I pass my own username and Windows network password...

How should I optimize this filesystem I/O bound program?

I have a python program that does something like this: Read a row from a csv file. Do some transformations on it. Break it up into the actual rows as they would be written to the database. Write those rows to individual csv files. Go back to step 1 unless the file has been totally read. Run SQL*Loader and load those files into the data...

Cannot Delete File Within A Child Process Started From A C# App

How do I invoke a child process from C# with UseShellExecute set to false and allow file deletion? The child process is a java program creates a 0 byte file, transfers it to a remote server, and deletes it. This functionality works when I execute the java program from the Windows command line. If I invoke the java program from C# usin...

Read a file from server with ssh using python

I am trying to read a file from a server using ssh from python. I am using paramiko to connect. I can connect to the server and run a command like 'cat filename' and get the data back from the server but some files I am trying to read are around 1 GB or more in size. How can I read the file on the server line by line using python? Addi...

How can you tell if a directory is writeable in Objective-C?

I want to use an open panel to let the user select a destination, but I want to alert them at that point that point that the directory is not-writable. I generally prefer to create it and handle the error, but that's not useful to me here, since I don't want to create the folder just yet. (I'll be sure to handle the error when I do creat...