io

Efficient copy from one file to another

I'm building a system in Java which has to copy a subset of a file into another file (not necessarily to the beginning of the file). I.e. I have the following parameters: File srcFile, File dstFile, long srcFileOffset, long dstFileOffset, long length Several threads could be reading from the same source-file and writing to the same des...

Are solid-state drives good enough to stop worrying about disk IO bottlenecks?

I've got a proof-of-concept program which is doing some interprocess communication simply by writing and reading from the HD. Yes, I know this is really slow; but it was the easiest way to get things up and running. I had always planned on coming back and swapping out that part of the code with a mechanism that does all the IPC(interpr...

UnauthorizedAccessException trying to delete a file in a folder where I can delete others files with the same code

I'm getting a Unauthorized Access Exception in a file wich I can delelete manually. in a folder where I'm able to delete by code other files and the file isn't marked as read only besides, I'm using windows XP in an standalone PC and I have not assigned any permissions to the folder or the file. any other process is using the file ...

Java I/O streams; what are the differences?

java.io has many different I/O streams, (FileInputStream, FileOutputStream, FileReader, FileWriter, BufferedStreams... etc.) and I am confused in determining the differences between them. What are some examples where one stream type is preferred over another, and what are the real differences between them? ...

interface hunt for something like Appendable or OutputStream

Hmmm. I'm trying to write a class that accepts bytes, and would like to implement a well-known interface for this purpose. java.io.OutputStream is an abstract class, not an interface (why???) and that makes me nervous, as I don't know what the consequences are of extending it. If there are no consequences, it should have been an interfa...

I/O prioritization in Java

I'd like to use of the Vista+ feature of I/O prioritization. Is there a platform independent way of setting I/O priority on an operation in Java (e.g. a library, in Java 7) or should I revert to a sleeping-filter or JNx solution? (Do other platforms have similar feature?) ...

Open a shared file under another user and domain?

I have a C# console application that needs to read a shared file on a machine in another domain. When the application tries to access the file an exception occurs as the local user does not have permission to access the shared resource. Currently I overcome this problem manually by open the shared folder from the run and put the usernam...

Exception handling issue

Hello. I have the following code: try { fi.MoveTo(getHistoryFileName()); } finally { Debug.Write("Move complete"); } I thought that using this would make sure that I'd never have exceptions thrown, but I am getting IOExceptions sometimes. What is the reason? ...

Python - tempfile.TemporaryFile cannot be read; why?

The official documentation for TemporaryFile reads: The mode parameter defaults to 'w+b' so that the file created can be read and written without being closed. Yet, the below code does not work as expected: import tempfile def play_with_fd(): with tempfile.TemporaryFile() as f: f.write('test data\n') f.wri...

Java: How do I read from PrintStream?

Hi, I am trying to read(append incoming data into a local String) from a PrintStram in the following code block: System.out.println("Starting Login Test Cases..."); out = new PrintStream(new ByteArrayOutputStream()); command_feeder = new PipedWriter(); PipedReader in = new PipedReader(command_feeder); ma...

What is ruby's StringIO class really?

I think I understand StringIO somewhat as being similar to java's StringBuffer class, but I don't really understand it fully. How would you define it and it's purpose/possible uses in ruby? Just hoping to clear up my confusion. Thanks ...

What is the best way to do a search in a large file?

I'm looking to apply a KMP (or similar) search to a large file (> 4GB). I'm expecting this to give me problems though.I can't copy it all to memory because there isn't enough space there. My question is, what is the best way to go about doing this search? Should I simply create a FILE* and do the search directly in the file, should I c...

C++ Real time console app, simultaneous input and output

I'm writing a quick server app for something so don't really want to write a full GUI. However the problem is that the main part of the server, however the console window will only allow input or output at a time. Many games ive played that have a console in them (usually needs activating in some way or another) they solved this problem...

Is it possible to read from a url into a System.IO.Stream object?

I am attempting to read from a url into a System.IO.Stream object. I tried to use Dim stream as Stream = New FileStream(msgURL, FileMode.Open) but I get an error that URI formats are not supported with FileStream objects. Is there some method I can use that inherits from System.IO.Stream that is able to read from a URL? ...

Most efficient way to create InputStream from OutputStream

This page: http://ostermiller.org/convert_java_outputstream_inputstream.html describes how to create an InputStream from OutputStream: new ByteArrayInputStream(out.toByteArray()) Other alternatives are to use PipedStreams and new threads which is cumbersome. I do not like the idea of copying many megabytes to new in memory Bytes a...

Using Java's FileInputStream

In java.io.FileInputStream, there is a method int read(Byte[] buffer,int offset,int numBytes); how we can use this function - is there any difference between this method and read(byte[] buffer)? ...

Non-destructible read from a stream.

Is is possible to try to read from a stream but do not change the stream itself (and return bool whether it was a success)? template <typename T> bool SilentRead (stringstream& s, T& value) { stringstream tmp = s; tmp >> value; return tmp; } This doesn't work because stringstream doesn't have public copy constructor. How t...

What is the optimal number of threads for performing IO operations in java?

In Goetz's "Java Concurrency in Practice", in a footnote on page 101, he writes "For computational problems like this that do not I/O and access no shared data, Ncpu or Ncpu+1 threads yield optimal throughput; more threads do not help, and may in fact degrade performance..." My question is, when performing I/O operations such as file wr...

I created a PrintWriter with autoflush on; why isn't it autoflushing?

My client is a web browser, and sending request to myserver using this url: http://localhost This is the server side code. The problem lies in the run method of the ServingThread class. class ServingThread implements Runnable{ private Socket socket ; public ServingThread(Socket socket){ this.socket = socket ; System....

Blocking IO vs non-blocking IO; looking for good articles

Once upon a time I bumped into Introduction to Indy article and can't stop thinking about blocking vs non-blocking IO ever since then. Looking for some good articles describing what are pros and cons of blocking IO and non-blocking IO and how to design your application in each case to get natural, easy to understand and easy to maintain...