io

Data Carving loop improvements.

I currently have a Python app I am developing which will data carve a block device for jpeg files. Let's just say that it sometimes works and sometimes doesn't. I have created it so that I read the block device till I find a ffd8, then I keep the stream open and search via looping for the ffd9 closure. Though I always need to take int...

ASP.net file operations delay

Ok, so here's the problem: I'm reading the stream from a FileUpload control, reading in chunks of n bytes and writing the array in a loop until I reach the stream's end. Now the reason I do this is because I need to check several things while the upload is still going on (rather than doing a Save(); which does the whole thing in one go)...

What are Mozilla Labs' Jetpack IO capabilities?

Are you able to access your file-system, using Jetpack, and do operations such as creating or reading files or saving images? ...

Writing a Modified Image to Disk

I have an image on my drive, I encrypted the bytes by adding a numerical value, now how can I write that modified file and replace the old one? Here's my encryption method [very newbish because I'm just getting a feel for things :P ]: private void EncryptFile() { OpenFileDialog dialog = new OpenFileDialog();...

Handling DoS due to unresponsive remote hosts

During a server start-up procedure, I access a remote host for some initialisation data. Unfortunately, the remote host in question is notorious for being randomly unresponsive to connections (lets say 3% of the time this happens). The result is that the connection hangs indefinitely (possibly forever), and my server doesn't start up in ...

Write all bits in C#

Hi How can i write all bits of a file using c#? For example writing 0 to all bits Please provide me with a sample ...

Lisp format and force-output

I don't understand why this code behaves differently in different implementations: (format t "asdf") (setq var (read)) In CLISP it behaves as would be expected, with the prompt printed followed by the read, but in SBCL it reads, then outputs. I read a bit on the internet and changed it: (format t "asdf") (force-output t) (setq var ...

Parsing CSV files in C#

Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser. Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a lot of people discourage this due to its "drawbacks." What are these drawbacks? Ideally, I'm looking for a way through which I can read th...

Listing files in a directory matching a pattern in Java

I'm looking for a way to get a list of files that match a pattern (pref regex) in a given directory. I've found a tutorial online that uses apache's commons-io package with the following code: Collection getAllFilesThatMatchFilenameExtension(String directoryName, String extension) { File directory = new File(directoryName); return ...

Fastest way of processing Java IO using ASCII lines

Hello, I'm working with an ASCII input/output stream over a Socket and speed is critical. I've heard using the right Java technique really makes a difference. I have a textbook that says using Buffers is the best way, but also suggests chaining with DataInputStreamReader. For output I'm using a BufferedOutputStream with OutputStreamWri...

How to determine the exact state of a BufferedReader?

I have a BufferedReader (generated by new BufferedReader(new InputStreamReader(process.getInputStream()))). I'm quite new to the concept of a BufferedReader but as I see it, it has three states: A line is waiting to be read; calling bufferedReader.readLine will return this string instantly. The stream is open, but there is no line wa...

Network I/O serialized

Why is network I/O serialized and not parallelized? ...

How to diagnose File.delete() returning false / find unclosed streams?

I'm working with a 3rd party JPEG/EXIF manipulation library (Mediautil) that is causing me some headaches. I want to change an image's EXIF data. To do this, I need to write the updated version to a temporary file, delete the original and then rename the temp file to the original name. My problem is that the File.delete() call fails an...

In Haskell, is there a way to do IO in a function guard?

For example: newfile :: FilePath -> IO Bool newfile x | length x <= 0 = return False | doesFileExist x == True = return False | otherwise = return True Can this be made to work? ...

How to Store a byte array as an image file on disk in Java?

I have a byte array representation of a Image. How to save it on disk as an image file. I have already done this OutputStream out = new FileOutputStream("a.jpg"); out.write(byteArray); out.flush(); out.close(); But when I open the image by double-clicking it, it doesn't show any image. ...

How should I store a large amout of text data in memory?

I am working on a c parser and wondering how expert manage large amount of text / string (> 100mb) to store in memory? the content is expected to be accessible all the time in fast pace. bg: redhat / gcc / libc a single char array would be out of boundary causing segmentation fault... any idea or experience is welcomed to share / dis...

How do I refer to a directory in Java?

I'm running Windows and I'm trying to refer to a directory. My function starts off like this: File file = new File("C:\\somedir\\report"); if (!file.exists()) { file.mkdirs(); } doStuffWith(file); I got a NullPointerException within the doStuffWith function, when I tried to call listFiles. Well I looked in C:\somedir and what did I ...

What are the alternative of monads to use IO in pure functional programming?

monads are described as the haskell solution to deal with IO. I was wondering if there were other ways to deal with IO in pure functional language. ...

How to write to I/O ports in Windows XP? (Delphi7)

I am trying to write to ports 0x60 and 0x64, with no luck. Delphi code: procedure PortOut(IOport: WORD; Value: BYTE); assembler; register; asm XCHG DX,AX OUT DX,AL end; Upon calling PortOut, I get an EPrivilege Privileged instruction exception, because IN and OUT may only execute as Ring0. I would like to know how I can get Ring...

reading an IsolatedStorageFile in Silverlight

I would like to take a file in isolatedstorage and convert it to a filestream for reading. how do I do this in code? ...