io

Java, Junit - Capture the standard input / Output for use in a unit test

I'm writing integration tests using JUnit to automate the testing of a console based application. The application is homework but this part isn't the homework. I want to automate these tests to be more productive -- I don't want to have to go back and retest already tested parts of the application. (Standard reasons to use Unit tests) ...

Java invalid stream header: 7371007E

Hi all, I am building a client-server application. Now I want to forward the message from a client to all other client with this code: ArrayList<User> usrs = _usrHandler.getUsers(); for(User usr : usrs) { if(!usr.getSocket().equals(_connection)) { usr._oOut.writeObject(new CommunicationMessage(this._comMsg.getMessage(), Com...

Fast data reading from CD-ROM

Hi, I have to read a large file containing many animation frames from CD/DVDrom and display it into screen as an animation. When reading from hard disk, the strategy of reading a frame into memory, processing, displaying and then reading next frame works good, but when I read from optical device, access time kills the animation. I use ...

Writing a file quite quick, overwriting the file take much longer...

I have been seeing a few performance problems with a PHP script on a Linux Fedora Core 11 box, so I was running some commands to look for a bottleneck. One thing I noticed was that writing a file is pretty quick: [root@localhost ~]# dd if=/dev/zero of=/root/myGfile bs=1024K count=1000 1000+0 records in 1000+0 records out 1048576000 byte...

Java: InputStream read() returns a byte bigger than 127?

Hi, I've this code: InputStream is = socket.getInputStream(); int b; while ((b = is.read()) != -1) { System.out.println(b); } A byte its range is -128 until +127. But one of the printed bytes is 210. Is this the result of converting the read byte to an int? (So that the negatif byte becomes a positif int) If so, can I do the same...

NIO: Send message and then disconnect immediately.

In some circumstances I wish to send an error message from a server to client using non-blocking I/O (SocketChannel.write(ByteBuffer)) and then disconnect the client. Assuming I write the full contents of the message and then immediately disconnect I presume the client may not receive this message as I'm guessing that the OS hasn't actu...

Any way to get a File object from a JAR

I have a JAR file that contains an API that uses external model files. I would like to include the model files in the JAR itself so it easier to use for other developers. The API will accept a File object only, is there any way to do this? I have already tried the following, and they have failed: Using class.getResourceAsStream(). ...

Getting an 'out of memory' exception in this relatively simple program.

Here's my Picture.cs class: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; using System.Drawing; namespace SharpLibrary_MediaManager { public class Picture:BaseFile { public int Height { get; set; } public int Width { get; set; } public Image Thumbn...

Delete last N bytes from file

There's a file on disk which can be very large. Is there any way to delete the last N bytes from it without copying the remaining content to another file? ...

Haskell's liftIO's litter functions of type ErrorT String IO ()

I have a function that returns type ErrorT String IO (). While the function works, liftIO's litter every line that does IO. It makes for a mess. Is there any way to get around this and still have the ability to abort on error? ...

How to forcefully unlock a file in c#?

I need to delete a file. Occasionally, the file may be locked, in this case I'd like to unlock it and delete it anyway. I've come across two possibilities in the research so far. System.IO.FileStream.Unlock and //unlock file [DllImport("kernel32.dll", SetLastError = true)] internal static extern bool UnlockFile(IntPtr handle, int of...

Exception: java.io.StreamCorruptedException: invalid type code: 00

When I query through the EJB interface for a entity, under the console it is ok, but switch to query from Swing it throw this exception. The exception: java.rmi.UnmarshalException: failed to unmarshal MY_ENTITY**; nested exception is: java.io.StreamCorruptedException: invalid type code: 00 at weblogic.rjvm.ResponseImpl.unmarsh...

Is there any way to route input/output from TinyScheme?

I'm using TinyScheme, and currently trying to route it's console input/output into my functions without on-disk file. I'm using Cocoa Touch, and final goal is making remote interactive console. I thinks some steps required, but I cannot how to implemented each steps. Especially, the how to using FILE structure. Any recommendations & ad...

create array of pointers to files

How would I go about making an array of file pointers in C? I would like to create an array of file pointers to the arguments of main... like a1.txt, a2.txt, etc... So I would run ./prog arg1.txt arg2.txt arg3.txtto have the program use these files. Then the argument for main is char **argv From argv, I would like to create the array of...

Interrupting epoll_wait with a non-IO event, no signals

Current scenario is epoll_wait over a couple of fds and a queue of possible incoming messages, I'd like the loop below epoll_wait to be executed on IO event or on new message. Ways I know: Use a time msec timeout and check the queue first thing in the loop Use the self-pipe trick from the queue code when messages become available Int...

Converting NTFS timestamps to FAT Timestamps

Hello world! I'm writing a file transfer application, and I need to copy files from NTFS to FAT drives. Reading from http://support.microsoft.com/kb/127830, I understand that a time such as #11/29/2004 7:31:06 PM, 250ms# should get translated to #11/29/2004 7:31:08 PM, 0ms# when copying to a FAT hard drive. However, what actually happen...

YUI3 IO program flow question

This may also be simple Javascript related but here is the link to IO just in case: YUI3 IO I have a YUI instance created and am using the io function to retrieve data from the server. YUI().use('event', 'node', 'io', function(Y) { Y.on('io:start', onstart, this, true); Y.on('io:success', changecontent, this); Y.on('io:en...

Testing IO actions with Monadic QuickCheck

Can anyone give me a brief example of testing IO actions using Monadic QuickCheck? ...

Are files in the temporary folder automatically deleted?

If I create some file using Path.GetTempPath() - does it automatically get deleted at some stage, or is it up to me to delete it? ...

reading a image file in java

how to read a image in java and convert it to buffered image? ...