io

Concurrently read from a single file

I have the following problem situation. A bunch of data is split across 10k small files (approx. 8-16 kib each). Depending on user input, I have to load these as fast as possible, and process them. More precisely, each data packet can be split into 100-100k files, and there are approximately 1k data packets. Most of them are the smaller ...

How can I implement an OutputStream that I can rewind?

After writing out some processed content to an output stream, I need to revisit the beginning of the stream and write out some content metadata. The data I'm writing is very large, as much as 4Gb, and may be written either directly to a file or to an in-memory buffer, depending on various environmental factors. How can I implement an O...

Only run thread when I/O load is low

I have a background thread that performs I/O operations (keeping an index up to date). But in addition to that several clients access the server's hard disk and I want these accesses as fast as possible. So I thought, it would be nice, if the indexing thread is only running when the I/O load is low. Is there a way to figure this out? I...

Piping Batch File output to a Python script

I'm trying to write a python script (in windows) that runs a batch file and will take the command line output of that batch file as input. The batch file runs processes that I don't have access to and gives output based on whether those processes are successful. I'd like to take those messages from the batch file and use them in the pyth...

Launch file from Java

I want to launch a file(a document) from a Java program and phase the following requirements: Method must be applicabale on Mac, Win and Linux systems I am not allowed to use "Runtime.getRuntime().exec("cmd.exe /C +"filename"); The file I am launching needs to be either of .doc / .docx / .rtf The file is created runtime, a result fro...

How do I determine whether two file system URI's point to the same resource ?

If I have two different file paths, how can I determine whether they point to the same file ? This could be the case, if for instance the user has a network drive attached, which points to some network resource. For example drive S: mapped to \servercrm\SomeFolder. Then these paths actually point to the same file: S:\somefile.dat A...

Directory.GetFiles() gives weird return values

This problem occurs when I try to hide a file in my directory with a tool named File Lock. This is not a regular hide as I can not see it in windows explorer. Code: string[] textFiles = Directory.GetFiles(@"c:\mydir") //0 files returned string[] textFiles = Directory.GetFiles(@"c:\mydir", "*.txt") //1 file returned: "c:\mydir\." File....

Why would I care about IOExceptions when a file is closed?

I've see this sort of thing in Java code quite often... try { fileStream.close(); } catch (IOException ioe) { /* Ignore. We do not care. */ } Is this reasonable, or cavalier? When would I care that closing a file failed? What are the implications of ignoring this exception? ...

How to redirect python warnings to a custom stream?

Let's say I have a file-like object like StreamIO and want the python's warning module write all warning messages to it. How do I do that? ...

Read vs. Write Times

Which operation is more time consuming - reading from a disk or writing to a disk for the same amount of data and the same memory location? ...

More robust file system library in .net

Let me rephrase. My example probably wasn't good. A lot of things can go wrong when deleting a directory. A file has a readonly attribute set, the directory is opened by the windows explorer. I guess all of them can be handled - however I don't want to do it on my own - is there a wrapper that takes care of that with a simple api? I fin...

How would you make a header that does a file reading function in c++

This may sound newbie but, I am trying to make an external header that does a function that is reading from a file a name like joey and saving it as a variable to the other code it read from but i cant figure it out...It will be like this...One code will get this name and it will write it to the file...Then i want to use this header to r...

open temp file in java

I'm writing string to temperoray file(temp.txt) and I want that file should open after clicking button of my awt window it should delete when I close that file (after opening that file), how can do this please help me. This is code what i have used to create temporary file in java File temp = File.createTempFile("temp",".txt"); FileWr...

How to redirect the output of .exe to a file in python?

In a script , I want to run a .exe with some command line parameters as "-a",and then redirect the standard output of the program to a file? How can I implement that? ...

How to suppress the carriage return in python 2?

myfile = open("wrsu"+str(i)+'_'+str(j)+'_'+str(TimesToExec)+".txt",'w') sys.stdout = myfile p1 = subprocess.Popen([pathname,"r", "s","u",str(i),str(j),str(runTime)],stdout=subprocess.PIPE) output = p1.communicate()[0] print output, When I use this to redirect the output of a exe to my own file, i...

tidy code for asynchronous IO

Whilst asynchronous IO (non-blocking descriptors with select/poll/epoll/kqueue etc) is not the most documented thing on the web, there are a handful of good examples. However, all these examples, having determined the handles that are returned by the call, just have a 'do_some_io(fd)' stub. They don't really explain how to best approac...

In Java what exactly does File.canExecute() do?

I have created a plain file which does not have execute permission but when I create a Java File object using this file's path/name and then call File.canExecute() I get true as the result, whereas I would expect this method call to return false. Can someone explain what I'm missing here? Solaris: $ touch /tmp/nonexecutable $ ls -l /t...

What are good tools to take IO measurements and discover bottlenecks on linux?

I'm trying to do some tuning for Oracle on Linux boxes living on SAN based infrastructure. I'm looking specifically for tools that would allow us to profile IO per process (or per process tree would be even better). My questions are? What are the tools that would be recommended for this kind of task? What other useful metrics should I ...

Should an object write itself out to a file, or should another object act on it to perform I/O?

NOTE: Sorry for the long question! I'm trying to understand some key areas behind object orientation and I couldn't decide one way or another about my particular question. Let's say I have an object full of lovely data. Class bob. Bob myBob = new Bob("This string is data"); Let's say I want to save the contents of myBob to an xml f...

When to flush a BufferedWriter ?

Hi, In a java program (java 1.5), I have a BufferedWriter that wraps a Filewriter, and I call write() many many times... The resulting file is pretty big... Among the lines of this file, some of them are incomplete... Do I need to call flush each time I write something (but I suspect it would be inefficient) or use another method of ...