file-io

Copy a directory while preserving symlinks using Java File/IO APIs

Is it possible to copy directory contents using the Java I/O and File-related APIs while preserving existing symlinks? I am working on a tool that needs to perform "directory copy" operations on a variety of UNIX flavours while preserving existing symlinks. I'd prefer to attempt this using the core Java SE libraries without resorting Ru...

using wild card when listing directories in python

how can I use wild cars like '*' when getting a list of files inside a directory in Python? for example, I want something like: os.listdir('foo/*bar*/*.txt') which would return a list of all the files ending in .txt in directories that have bar in their name inside of the foo parent directory. how can I do this? thanks. ...

Naming a file downloaded from url in iPhone

I would like to save a file downloaded from the internet in iPhone. Can I use the url as the file name? If not, what transformation should I apply to the url to obtain a valid file name? I need to find the local copy of the file later using its url. Edit: Not asking where or how to write a file to disk. The question is limited to get...

Writing to a file in Python inserts null bytes

I'm writing a todo list program. It keeps a file with a thing to do per line, and lets the user add or delete items. The problem is that for some reason, I end up with a lot of zero bytes at the start of the file, even though the item is correctly deleted. I'll show you a couple of screenshots to make sure I'm making myself clear. This ...

Simple binary File I/O problem with cstdio(c++)

The c++ program below fails to read the file. I know using cstdio is not good practice but that what I am used to and it should work anyway. $ ls -l l.uyvy -rw-r--r-- 1 atilla atilla 614400 2010-04-24 18:11 l.uyvy $ ./a.out l.uyvy Read 0 bytes out of 614400, possibly wrong file code: #include<cstdio> int main(int argc, char* argv[...

how to convert mp4 to mp3 in java

Hi, I'm looking for a minimal way to convert mp4 file to mp3 file programmatically from Java. Ideally I also need an cutting of target file. Do Java libs support this or only 3th party ones? Like jmf, ffmpeg? Thanks! ...

Is appending to a file atomic with Windows/NTFS?

If I'm writing a simple text log file from multiple processes, can they overwrite/corrupt each other's entries? (Basically, this question http://stackoverflow.com/questions/1154446/is-file-append-atomic-in-unix but for Windows/NTFS.) ...

Preventing threads from writing to the same file

I'm implementing an FTP-like protocol in Linux kernel 2.4 (homework), and I was under the impression that if a file is open for writing any subsequent attempt to open it by another thread should fail, until I actually tried it and discovered it goes through. How do I prevent this from happening? PS: I'm using open() to open the file....

Recommendations for a C++ polymorphic, seekable, binary I/O interface

I've been using std::istream and ostream as a polymorphic interface for random-access binary I/O in C++, but it seems suboptimal in numerous ways: 64-bit seeks are non-portable and error-prone due to streampos/streamoff limitations; currently using boost/iostreams/positioning.hpp as a workaround, but it requires vigilance Missing opera...

File writing with overlapped IO vs file writing in a separate thread

Is there any advantage in using file writing with overlapped IO in Windows, vs just doing the file writing in a separate thread that I create? [Edit - please note that I'm doing the file writes without system caching, ie I use the FILE_FLAG_NO_BUFFERING flag in CreateFile) ...

synchronizing XML nodes between class and file using C#

I'm trying to write an IXmlSerializable class that stays synced with an XML file. The XML file has the following format: <?xml version="1.0" encoding="utf-8" ?> <configuration> <logging> <logLevel>Error</logLevel> </logging> ...potentially other sections... </configuration> I have a DllConfig class for the whole XML file an...

What Is The Replace Function In Python

I want to write a python code that open a text file and Replace with a word that i want send to it . May you give me an example ? Thanks . ...

Prompt with UAC when user doesn't have access to copy a file

In my application, if the user saves a file to a folder they don't have permissions for, File.Copy will fail. An example is saving a document to the C:\ root. Instead of denying access, I'd like to prompt the user to elevate permissions with a UAC prompt, but only for this save function (not for the entire application). Is there a way t...

Does anyone know some Java class that return a operating system friendly filename?

I have an uploader in my web page, but some people upload files named like "compañia 15% *09.jpg" and i have problems when the filenames are like that one. I would like to found a class that returns for that example something like this: "compania1509.jpg". ...

Need a way to determine if a file is done being written to.

The situation I'm in is this - there's a process that's writing to a file, sometimes the file is rather large say 400 - 500MB. I need to know when it's done writing. How can I determine this? If I look in the directory I'll see it there but it might not be done being written. Plus this needs to be done remotely - as in on the same int...

Any Alternate way for writing to a file other than ofstream

Hi All, I am performing file operations (writeToFile) which fetches the data from a xml and writes into a output file(a1.txt). I am using MS Visual C++ 2008 and in windows XP. currently i am using this method of writing to output file.. 01.ofstreamhdr OutputFile; 02./* few other stmts */ 03.hdrOutputFile.open(fileName, std::ios::o...

How to count lines of a file in C++?

Hi, In C++, how can I count lines using the standard classes fstream, ifstream? Thank you, Mohammad ...

File Not Found Error

Hi, I've passed a file to a library, and the library is spitting out a FileNotFound error as shown: javax.xml.transform.TransformerException: java.io.FileNotFoundException: file:\C:\Users\Oroma\workspace\IndividualProject_JINQS\WebContent\WEB-INF\classes\presentationlayer\utility\mappings\jmt\networkModel.xml (The filename, directory ...

How to write a file with CRLF line breaks in Objective-C?

Hi, I need to create and export an excel file in my iPhone app. Unfortunately, excel won't read it if the line encoding is LF (the unix default when I write the file) instead of CRLF (the Windows standard)...Is there any way to write a file using CRLF line breaks? I can tell this is the issue as if I open the file in TextWrangler a...

Reading a file with variable line lengths line by line in c

Hey everyone, In C, is there a way to read a text file line by line without knowing how much space to allocate for it? here's an example of what I mean: fgets(line, <dynamic line size>, fileHandle); Thanks for the help! ...