io

Create a Java File object (or equivalent) using a byte array in memory (without a physical file)

I want to create a Java File object in memory (without creating a physical file) and populate its content with a byte array. Can this be done? The idea is to pass it to a Spring InputStreamSource. I'm trying the method below, but it returns saying "the byte array does not contain a file name.". MimeMessage message = mailSender.create...

What is an "async IO operation" in .NET?

To cut a long story short - read this article first and then this article. In short - it's the old issue about ASP.NET and randomly switching among threads. Well, not so randomly actually. As the second article explains, this only happens "when your thread performs an async IO operation". So... what the heck is an async IO operation in t...

Difference between StreamReader.Read and StreamReader.ReadBlock

The documentation simply says ReadBlock is "a blocking version of Read" but what does that mean? Someone else has asked the question before but, huh? http://www.pcreview.co.uk/forums/thread-1385785.php The guy answering said "Basically, it means that you can rely on StreamReader.ReadBlock not returning until either it's read as mu...

What's the best way to monitor an InputStream?

I'm reading a file in via apache.commons.FtpClient. This works fine 99.9% of the time but sometimes it just dies in the read() method... InputStream inStream = ftp.retrieveFileStream(path + file.getName()); String fileAsString = ""; if(inStream == null){ return; } while((c = inStream.read()) != -1){ //this is where the code someti...

C++ and C file I/O

C++ file i/o is tougher than c file i/o. So in c++, creating a new library for file i/o is useful or not? I mean Can anyone pls tell are there any benefits in c++ file i/o ? ...

How do you get a file in C++?

So the teacher has posed this assignment: You have been hired by the United Network Command for Law Enforcement, and you have been given files containing null cyphers you have to decrypt. So for the first file given (as an example), every other letter is correct (ie: 'hielqlpo' is hello (assuming you start with the first letter). My f...

What is the fastest way to read a large number of small files into memory ?

I need to read ~50 files on every server start and place each text file's representation into memory. Each text file will have its own string (which is the best type to use for the string holder?). What is the fastest way to read the files into memory, and what is the best data structure/type to hold the text in so that I can manipulate...

File not found. Why not?

Okay, I'm trying to load a file in Java using this code: String file = "map.mp"; URL url = this.getClass().getResource(file); System.out.println("url = " + url); FileInputStream x = new FileInputStream("" + url); and despite the file being in the same folder as the class it says it can't find it (yes, it is in a try catch block in the...

How can I buffer non-blocking IO?

When I need buffered IO on blocking file descriptor I use stdio. But if I turn file descriptor into non-blocking mode according to manual stdio buffering is unusable. After some research I see that BIO can be usable for buffering non-blocking IO. But may be there are other alternatives? I need this to avoid using threads in a multi-co...

How to write bits to a file?

How to write bits (not bytes) to a file with c#, .net? I'm preety stuck with it. Edit: i'm looking for a different way that just writing every 8 bits as a byte ...

Writing a binary buffer to a file in python

Hi there, I have some python code that: Takes a BLOB from a database which is compressed. Calls an uncompression routine in C that uncompresses the data. Writes the uncompressed data to a file. It uses ctypes to call the C routine, which is in a shared library. This mostly works, except for the actual writing to the file. To uncomp...

.net Text delimited libraries?

Does the .net framework have any builtin assemblies for handling reading and writing from and to text delimited files? Or is this something I have create myself? ...

Delphi - Enumerating SATA IO Port Numbers in Windows

New one for you. Im getting ready to help another programmer port his program from C# to Delphi. I cant truly read C# nor has he sent me actual source at this point so from discussion i think im going to be tackling most of this from a one function at a time standpoint. I need to be able to get the IO Port Numbers for all SATA devices...

Haskell: How to pipe the contents of one handle into another in real time.

I am writing a program that runs an external sub process interactively and I need the contents of the output handle to be output to stdout as soon as it is available. I have tried something like this: main = do processInfo <- createProcess (proc "ghci" []){std_out = CreatePipe, std_in ...

C# threads for file manipulation

I have to be able to save a file, unfortunatly it can potentially be very large so saving it can potentially take minutes. As I need to do this from a GUI thread I don't want to block the GUI from executing. I was thinking about attempting the save operation on a seperate thread to allow the primary GUI thread to continue executing. Is ...

Remove file in C++ under UNIX

How do you guys typically delete files on Linux OS? I am thinking of using the unlink function call, but I wonder if you have a better idea, as the C++ standard has no mention of file deletion operation and it is system dependent. ...

open file in exclusive mode in C#

Hello everyone, I want to open a file for read in exclusive mode, and if the file is already opened by some process/thread else, I want to receive an exception. I tried the following code, but not working, even if I opened the foo.txt, I still can reach the Console.WriteLine statement. Any ideas? static void Main(string[] args) { u...

Java: Quickly read the last line of a text file?

What's the quickest and most efficient way of reading the last line of text from a [very, very large] file in Java? ...

Python game programming: is my IO object a legitimate candidate for being a global variable?

Hello Stackoverflow, I'm programming a game in Python, where all IO activities are done by an IO object (in the hope that it will be easy to swap that object out for another which implements a different user interface). Nearly all the other objects in the game need to access the IO system at some point (e.g. printing a message, updating...

Cheap way to improve I/O

I see http://www.youtube.com/watch?v=96dWOEa4Djs from http://www.joelonsoftware.com/items/2009/03/27.html and get amazed of the improvenment. I have a good workstation (Sun Ultra M4, 2 AMD Opteron, 8GB RAM, NVidia FX 1500) and feel as fast as... any other computer in the city (except when rendering). I blame windows for it (I can't use...