file-io

Java File Cursor

Hi, Is there some library for using some sort of cursor over a file? I have to read big files, but can't afford to read them all at once into memory. I'm aware of java.nio, but I want to use a higher level API. A little backgrond: I have a tool written in GWT that analyzes submitted xml documents and then pretty prints the xml, among o...

Writing to a FileStream behaves strangely, as observed by process monitor

I'm using FileStream to write to a file, and watching the underlying system calls using Process Monitor. I'm having trouble with some file locking issues in a production deployment, so I'm looking at the details closely. This sample code: using (FileStream fs = new FileStream("c:\\temp\\test.txt", FileMode.Create, FileAccess.W...

File Upload with Java (with progress bar)

I'm extremely new to Java, and have mostly just been teaching myself as I go, so I've started building an applet. I'd like to make one that can select a file from the local disk and upload it as a multipart/form-data POST request but with a progress bar. Obviously the user has to grant permission to the Java applet to access the hard dri...

Ruby on Rails XML generation

I am attempting to build a simple method that creates an XML file from a database in ruby on rails. I feel like my code is right but I am not seeing all of the users in the XML. I am a complete newbie to RoR. Here's my code: def create_file @users = User.find(:all) file = File.new('dir.xml','w') doc = Document.new make = Ele...

When should I use mmap for file access?

POSIX environments provide at least two ways of accessing files. There's the standard system calls open(), read(), write(), and friends, but there's also the option of using mmap() to map the file into virtual memory. When is it preferable to use one over the other? What're their individual advantages that merit including two interfac...

Does .NET (Mono) support cross-platform file operations and cross-platform audio metadata handling (through libraries)?

For my next project, the two leading frontrunners are .NET and Java. The project is to take a directory (something like My Music in Windows) that contains directories and music files (MP3s initially, but eventually expanded to other music formats). For each file, it would allow you to play the file and view/edit its metadata, filename, a...

Why is my simple C program displaying garbage to stdout?

Consider the following simple C program that read a file into a buffer and displays that buffer to the console: #include<stdio.h> main() { FILE *file; char *buffer; unsigned long fileLen; //Open file file = fopen("HelloWorld.txt", "rb"); if (!file) { fprintf(stderr, "Unable to open file %s", "HelloWorl...

Java BufferedReader back to the top of a text file?

I currently have 2 BufferedReaders initialize on the same text file. When I'm done reading the reading the text file with the first BufferedReader, I use the second one to make another pass thru the file from the top. Multiple passes thru the same file are necessary. I know about reset(), but it needs a previous call to mark() and mark...

Fastest way to create large file in c++ ?

Create a flat text file in c++ say 50 - 100 MB say the content like 'Added first line' should be inserted in to the file for 40 lakhs time ...

How does default/relative path resolution work in .NET?

So... I used to think that when you accessed a file but specified the name without a path (CAISLog.csv in my case) that .NET would expect the file to reside at the same path as the running .exe. This works when I'm stepping through a solution (C# .NET2.* VS2K5) but when I run the app in normal mode (Started by a Websphere MQ Trigger...

c++ file io & splitting by separator

I have a file with data listed as follows: 0, 2, 10 10, 8, 10 10, 10, 10 10, 16, 10 15, 10, 16 17, 10, 16 I want to be able to input the file and split it into three arrays, in the process trimming all excess spaces and converting each element to integers. For some reason I can't find...

How do I find the file handles that my process has opened in Linux?

When we perform a fork in Unix, open file handles are inherited, and if we don't need to use them we should close them. However, when we use libraries, file handles may be opened for which we do not have access to the handle. How do we check for these open file handles? ...

What’s the best way to check if a file exists in C++? (cross platform)

I have read the answers for this question but I'm wondering if there is a better way to do this using standard c++ libs? Preferably without trying to open the file at all. Edit: Thanks for the answers so far, but I'm still stuck... Both "stat" and "access" is pretty much ungoogleable. What should I #include to use these? ...

Storing temporary user files in ASP.NET in medium trust

I have a scenario where users of my ASP.NET web application submit testimonials consisting of text info and images. The submit process has the following steps: First the user inputs the content and chooses a path to an image When he clicks preview, the info is once again shown so that he can confirm Once confirmed the info is persisted...

How to copy a file in Python with a progress bar?

When copying large files using shutil.copy(), you get no indication of how the operation is progressing.. I have put together something that works - it uses a simple ProgressBar class (which simple returns a simple ASCII progress bar, as a string), and a loop of open().read() and .write() to do the actual copying. It displays the progre...

do you do the following operations in C++?

Hi all, how do you do the following operations in C++? Opening Files Closing Files Reading Files Writing Files ...

What is the best way to transfer a file using Java?

I am writing code for uploading a file from a client to my server and the performance isn't as fast as I think it should be. I have the current code snippet that is doing the file transfer and I was wondering how I could speed up the transfer. Sorry about all of the code: InputStream fileItemInputStream ; OutputStream saveFileStream; ...

Applescript application read from file

I have a compiled applescript application which I have moved to my windows server. I'd like to then insert a text file into the application (which looks like a zip file on windows): myapplescript.app/Contents/Resources/MyNewDir/MyTxtFile.txt So, i've precompiled the applescript to try to read from this text file and get the contents as...

Best way to take a snapshot of an object to a file.

What's the best way to output the public contents of an object to a human-readable file? I'm looking for a way to do this that would not require me to know of all the members of the class, but rather use the compiler to tell me what members exist, and what their names are. There have to be macros or something like that, right? Contrived...

php: writing files

Hi All, I want to create a file on the webserver dynamically in PHP. First I create a directory to store the file. THIS WORKS // create the users directory and index page $dirToCreate = "..".$_SESSION['s_USER_URL']; mkdir($dirToCreate, 0777, TRUE); // create the directory for the user Now I want to create a file called index.php and...