file-io

Java: writing to a file, where is the output file ?

FileWriter outFile = null; try { outFile = new FileWriter("member.txt"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } out.println("test"); Running that command, where is the member.txt ? I am using windows vista. UAC enabled so wh...

java - file read/write problem

hi, i m having a really weird error: i am using buffered reader (br) and writer(bw) to read from one file - do calculation and write to another file. problem: the first file does not get written to the new file completely. LAst couple of lines get truncated. I tried putting a print statement to see if the file is getting read - and all ...

Loading XML is VERY slow

Hello, I inherited a data-storage which was using simple text-files to save documents. Documents had some attributes (date, title, and text), and these were encoded in a filename: <date>-<title>.txt, with the body of the file being the text. However in reality Documents in the system have many more attributes, and even more again were...

Quickly remove first n lines from many text files

I need to create an output text file by deleting the first two lines of the input file. At the moment I'm using sed "1,2d" input.txt > output.txt I need to do this for thousands of files, so am using python: import os for filename in somelist: os.system('sed "1,2d" %s-in.txt > %s-out.txt'%(filename,filename)) but this is quite slo...

How to write data in specified format into a binary file with Perl?

Hi all, this might be quite a newbie question, but i need to process a certain text file and dump its content into a binary file and i do not know how - i decided to use perl, but my perl skills are quite low. I probably should have written this in C++, but this seem like a nice and easy task for perl, so why not learn something new? ;)...

Writing to new file

I am using FileOutputStream for writing some data to a file. Every time I execute my program, it appends the data to existing file instead of creating new one. I want to create a new file every time I execute the program. How do I do that? ...

Forcing closed an open file by C#

I found a similar question here but it was closed/accepted with an answer of "don't do that". I'm in a situation where I don't care what happens to the other applications, I want to take a file that may be locked by others (rudely if needed) and have my way with it. I may need to move, rename, or delete this file. Basically I need to ...

what is the folder of sdcard and how can i create files and read and write them in it.

please somebody tell me what is the folder of sdcard and how can i create files in it.because i am new to android and i have googled so much but could not find any comprehensive stuff.i want to create file in sdcard manually. please help. here is my code i have written but now it says fileNotFoundException. hence i have created a file i...

Is there a c++ way to write file with any type of data

Like this function in C: size_t fwrite ( const void * ptr, size_t size, size_t count, FILE * stream ); I've looked in c++ file stream and found this one: ostream& write ( const char* s , streamsize n ); this one only accepts char* instead of void* but does it really matter if i use a c-style fwrite function in c++> ...

PHP Regular Expression to match define() function

Hi people I'm doing a translation of php script and want to gain some time by doing some automatization The file contains very large number of lines like these define('LNG_NewsletterNameIsNotValid', 'Email Campaign name is not Valid'); define('LNG_UnableToCreateNewsletter', 'Unable to create an Campaña de Email'); define('LNG_HLP_Newsle...

Reading from a file

hello i got a problem with reading from a file, i am trying to read from a file using fscanf() and i cant seem to sort it out. i try to read the file line by line and putting the string in a variable (buffer) each time but i cant understand how the while loop is suppose to be looking like thanks in advance the file that i want to read f...

Read/Write binary file with structure of fixed length

I need to read/write file which as light as possible and with super-fast read and write access. In other words, I cannot use serialization or binary serialization. I have to be able to update a single records and seek in the file quickly. Essentially, I need a file structure similar to what I would do in C/C++ (i.e. fixed size structure...

File I/O in Every Programming Language

This has to be a common question that all programmers have from time to time. How do I read a line from a text file? Then the next question is always how do i write it back. Of course most of you use a high level framework in day to day programming (which are fine to use in answers) but sometimes it's nice to know how to do it at a low...

How can I use AVAssetExportSession to overwrite songs in my iPhone/iPod library?

So supposedly in the iOS 4 SDK you can edit and write to the user's iTunes library. I can successfully load an AVAsset from my iPhone/iPod library, but as a quick test I'm trying to just overwrite the same file right away using AVAssetExportSession but it's always returning the status "4" which I THINK is AVAssetExportSessionStatusFailed...

Deleting an arbitrary chunk of a file

What is the most efficient way to delete an arbitrary chunk of a file, given the start and end offsets? I'd prefer to use Python, but I can fall back to C if I have to. Say the file is this ..............xxxxxxxx---------------- I want to remove a chunk of it: ..............[xxxxxxxx]---------------- After the operation it should...

When do we should use a scatter/gather(vectored) IO?

Windows file system supports scatter/gather IO.(Of course, other platform does) But I don't know when do I use the IO mechanism. Could you explain me a proper case? And what benefit can we get from using the I/O mechanism?(Just a little IO request?) ...

Android writing to a CSV file via OpenCsv

I try to write to a Csv file via: mFileWriter = new FileWriter( "/sdcard/program/file"); mCsvWriter = new CSVWriter(mFileWriter); At the moment it throws an exception that the file doesn't exist. It's true that the file doesn't exist. What's the easiest way to create the file? ...

fread Only first 5 bytes of .PNG file

I've made a simple resource packer for packing the resources for my game into one file. Everything was going fine until I began writing the unpacker. I noticed the .txt file - 26 bytes - that I had packed, came out of the resource file fine, without anyway issues, all data preserved. However when reading the .PNG file I had packed in the...

(Accès refusé) Access Denied exception

I m accessing file from java application, but i m getting following exception c:\Program Files\sample\sample\cample.xml (Acc?s refus?) at java.io.FileOutputStream.(Unknown Source) at java.io.FileOutputStream. at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) ...

How do I write to a file in Matlab?

I have an mXn matrix of integers. I want to write the matrix to a text file. I also want to read the file later and assign the values to another mXn matrix. How? EDIT: I want it to be as easy as possible to later load the content of the file to a variable in matlab (a matrix). I also might use the file in a C program where I load the nu...