io

How to add a string to end of a .txt file?

How can I add a string to the end of a .txt file? ...

Why FileOutputStream does not throw OutOfMemoryException

Hi, I've tried the code below on both Windows (64bit) and Linux(32bit). I was sure that without BufferedOutputStream the code is bound to throw OutOfMemoryException yet it didn't. Why is that? Who is doing the {caching / buffer / steaming} to disk there? Can you please describe, if relevant to the answer, the full flow (Java API ->...

How to read multiple files in parallel?

I have a number of text files that I need to open, then allocate certain fields to set strings inside PHP to eventually write into MySQL. Each txt file does have the same unique value for app_id, eg So text file 1 has app_id name description text file 2 has app_id category text file 3 has app_id price I want to get name, descript...

SQL Server 2008 large table performance

Hey all, I have this relatively large table in a separate filegroup (2 GB, well, it's not THAT large but large enough I think to start thinking about performance as it's a heavy duty table). This is the only table in this filegroup. Right now the filegroup contains only one datafile. Assuming the table is well-indexed and that index ...

finding out absolute path to a file from python

if I have a file test.py that resides in some directory, how can I find out from test.py what directory it is in? os.path.curdir will give the current directory but not the directory where the file lives. If I invoke test.py from some directory "foo", os.curdir will return foo but not the path of test.py. thanks. ...

Speed Up download time

Hi I have 40 MB file in server and i am downloading my file using HttpURLConnection c = (HttpURLConnection) u.openConnection(); c.setRequestMethod("GET"); c.setDoOutput(true); c.connect(); FileOutputStream f = new FileOutputStream(new File("trips.xml")); InputStream in = c.getInputStream(); byte[] buffer = new byte[1024]; in...

Difference between using StreamWriter constructor and File.CreateText

What's the difference (CPU usage, MSIL, etc) between: StreamWriter sw = new StreamWriter("C:\test.txt"); and: StreamWriter sw = File.CreateText("C:\test.txt"); ? ...

How do I retrieve and image datatype from SQLServer 2005 without programmatic access from some other language.

I have a SQL Server 2005 table with an image datatype as on of the table fields. I have a specific row I am interested. I'd like to write the binary data in the image field to a file on a network share. Let's call the share \server\sharename ...

Cocoa equivalent to Java's Reader classes

In porting a Java program to Cocoa, I've come across the program using java.io.Reader and its subclasses. I'm not very familiar with what they do, so I can't find a good replacement. Does anyone have any good recommendations on replacements or do I have to rewrite it? ...

Java Non-blocking Read

Hello, I'm trying to read in from two different input streams (stdin and stderr of a child application) and print them in one combine frame. I've never done this before, and am wondering about best practices. I can spawn two threads and let them both block on the input stream. Is there a better way? Thanks! ...

Using Java's ByteBuffer to read millions of messages...

Here's my problem: one big gzipped file; millions of messages. Each message consists of: ***************** *************** ****************** * 2-byte LENGTH * * 1-byte TYPE * * N-byte PAYLOAD * , where N = (LENGTH-1). ***************** *************** ****************** Depending on the TYPE, I need to read a few bytes from an off...

C# Working with files/bytes

Hello, I have some questions about editing files with c#. I have managed to read a file into a byte[]. How can I get the ASCII code of each byte and show it in the text area of my form? Also, how can I change the bytes and then write them back into a file? For example: I have a file and I know the first three bytes are letters. How ...

Python library for monitoring /proc/diskstats?

Hi, I would like to monitor system IO load from a python program, accessing statistics similar to those provided in /proc/diskstats in linux (although obviously a cross-platform library would be great). Is there an existing python library that I could use to query disk IO statistics on linux? ...

IO Question: Writing a portion of a file

I have a general IO question. I was trying to replace a single line in an ascii encoded file. After searching around quite a bit I found that it is not possible to do that. According to what I read if a single line needs to be replaced in a file, the whole file needs to be rewritten. I read that this is the same for all OS's. After readi...

Only disk writes but iotop shows reads as well

Hi, I'd like to understand the following issue: A process is doing write sys call only, in an infinite loop. When I bring up iotop I would expect to see non-zero write speed and zeroed read speed related to that process. But iotop tells read and write can be equal (depending on single write size). Have a look at the C code: #include <...

Creating a custom reader class in java

I am try to solve a prob in one of the Programming contests.The actual prob is sort a given list of numbers.I am using a algorithm with complexity(nlog n) and that is the maximum level of optimization I can do with the algorithm.Now from the forum I understood that I need a faster I/O for which I should create a new reader class.I/O are ...

Is Java's EOFException exceptional?

It seems dirty to use an exception to indicate the end of a file has been reached. Every file we read has an end, so it doesn't seem exceptional or unexpected. Furthermore, I don't like using an exception for the non-exceptional flow of my program. I'm talking about using java.io.EOFException to signal the end of a data input stream: I...

Java, IO - fastest way to remove file.

Hey guys, My problem is that I have an app which is writing a lot of relatively (100-500kb) small CSV files (tens and hundreds of thousands ). Content of those files then get loaded in database via sql loader call (its oracle db) and this is what I have to live with. So, I need to remove those small files time to time to prevent them...

win32api vs Python

What are the Pro's and Con's of using win32api for I/O and other things instead of simply Python, if both have a specific function for it I mean, using PyWin32 vs Win32Api ...

Use cases of PipedInputStream and PipedOutputStream

What are use cases of Piped streams? Why just not read data into buffer and then write them out? ...