io

putStrLn, type Char does not match [Char]

I have an haskell problem. putStrLn is supposed to take a [Char], or a String, and even though it seems like I give that to mr Compiler, he still complains. *** Expression : putStrLn line *** Term : line *** Type : Char *** Does not match : [Char] The code that it refers to is this: getV::[[(Char,Float)]] -> I...

Fastest way in C# to read block of bytes from file and converting to float[]

Hi! I need a fast way in C# leanguage of converting/casting array of bytes encoding one short (int16) value for 2bytes into float representation, as fast as possible. Performance bottleneck was method: samples[sample] = (float)binraryReader.readInt16(); (huge ammount of IO calls so i had to convert to block read) Basically i have fil...

Can I ensure that Haskell performs atomic IO?

I have two threads in haskell that perform IO. (They print only). Something like the following: thread1 :: IO () thread1 = putStrLn "One" thread2 :: IO () thread2 = putStrLn "Two" I am currently getting results like the following: OnTwoe OTnweo How can I ensure that each thread completes its IO atomically? ...

read url in binary mode in java

In java I need to read a binary file from a site and write it to a disk file. This example http://java.sun.com/docs/books/tutorial/networking/urls/readingURL.html could read webpages succesfully, but when I try to read a binary file from my localhost server and write it to a disk file the contents change, corrupting the binary file. Usin...

How can I modify the application file of an application that is currently running (on Linux)?

I have an application running called AppFS. This application has an ext2 filesystem just attached to the end of the file (it's positioned so that the application binary exists in a 1MB spacing area, followed by the ext2 data). Now I've got FUSE embedded in the program and I've managed to extract the filesystem out of the application da...

gdi+ removable device IO Safe problem

I am using gdi+ for image format checking. It is really surprising that gdi+ Image img(path); does not throw exception when a device is removed. for example, I am checking a list of image files on a removable device. I plug the disk off, Then My Application will crashed. How can I avoid such problem? Many Thanks! I am using c++ gdi+ wi...

Writing to an already existing file using FileWriter Java

Is there anyway I can write to an already existing file using Filewriter For example when the user clicks a submit button: FileWriter writer = new FileWriter("myfile.csv"); writer.append("LastName"); writer.append(','); writer.append("FirstName"); writer.append('/n'); writer.append(LastNameTextField.getText()); writer.append(','); wri...

What is the proper way to code a read-while loop in Scala?

What is the "proper" of writing the standard read-while loop in Scala? By proper I mean written in a Scala-like way as opposed to a Java-like way. Here is the code I have in Java: MessageDigest md = MessageDigest.getInstance( "MD5" ); InputStream input = new FileInputStream( "file" ); byte[] buffer = new byte[1024]; int readLen; while...

What is the magic behind perl read() function and buffer which is not a ref ?

I do not get to understand how the Perl read($buf) function is able to modify the content of the $buf variable. $buf is not a reference, so the parameter is given by copy (from my c/c++ knowledge). So how come the $buf variable is modified in the caller ? Is it a tie variable or something ? The C documentation about setbuf is also quit...

create a sparse BufferedImage in java

I have to create an image with very large resolution, but the image is relatively "sparse", only some areas in the image need to draw. For example with following code /* this take 5GB memory */ final BufferedImage img = new BufferedImage( 36000, 36000, BufferedImage.TYPE_INT_ARGB); /* draw something */ Graphics g = img.getG...

Python: slow read & write for millions of small files

Conclusion: It seems that HDF5 is the way to go for my purposes. Basically "HDF5 is a data model, library, and file format for storing and managing data." and is designed to handle incredible amounts of data. It has a Python module called python-tables. (The link is in the answer below) HDF5 does the job done 1000% better in sa...

How do I read a file from a package - something like a resource bundle in Java

I have a words.txt file that I have put in a particular java package and would need to read it from that same location. I do not control the deployment, so I don't know where the packages will be deployed. Example location: com/example/files/words.txt . I know how to use the ResourceBundle class to read properties file from the packag...

Creating a Delay in lua

I'm making a IRC client using LUA. I'm using the the libraries that came with "Lua for Windows ". So I'm using luasocket for the comms and IUP for the UI bits. The problem I'm having is that I'm getting stuck in a loop when I read the IO. I tried the timer in IUP but that didn't seem to work. I'm was looking for a way to delay the IO r...

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 ...

What happens when you send an 8bit number to an output which is 4bit? C Language

I'm studying in high school, and we have an electronics project. We have an output from our computer which is 4 bit, output address is 37Ah and my teacher did this: outportb(0x37A,0x80); so what will appear in the output? 0h or 8h? ...

Problem between IO heavy operations and network application listening for UDP and SCTP data.

We have an application that uses two types of socket, a listening UDP socket and an active SCTP socket. At certain time we have scripts running on the same machine that have high IO activities (such as "dd, tar, ..."), most of the time when these IO heavy applications run we seem to have the following problems: The UDP socket closes T...

Math in python - converting data files to matrices

Hello! Today, as I tried to put together a script in Octave, I thought, this may be easier in python. Indeed the math operators of lists are a breeze, but loading in the file in the format is not as easy. Then I thought, it probably is, I am just not familiar with the module to do it! So, I have a typical data file with four columns ...

when is parallelizing disk i/o worth the effort?

Based on your experience, have you gained performance boost from parallelizing disk I/O? I/O reads in particular In my case, I though having RAID 0 drives would allow to run at least two reads concurrently, but it still is slower than the serial approach. Would you ever go for concurrent I/O reads? Why? ...

Google I/O Android Sample Application

Hey all, I heard recently that Google were to opensource the Google I/O Android application - the one which showed the next available talk, speaker info, etc. Does anyone know whether this is true, and if it is, do you know where I can access the source? On a related note, does anyone know of a sample application which concentrates on ...

Displaying a programs output in Cocoa.

Hi, What view would be the best view for displaying text from the console? In particular output of a C program? For example if I used system("gcc foo.c"); in my program and then wanted to display the output of that what view would a I use and how would I display it? Also, how would I get input too? ...