io

Simple C++ Writing to File: Nothing Gets Written! Should be easy, but I'm stumpted.

Thank you so much for helping me! Everyone is so fast and excellent! Thanks again! What is happening is no data is being written to my file, after I test this code. Just a 0 appears. What am I doing wrong? void CreateHtmlFile(string myMessages[]) { int i = 0; int emptyarray = 0; int myEmptyCounter = 0; int emptyArrayCounter = ...

Replace string in file

Hi, I'm looking for a way to replace a string in a file without reading the whole file into memory. Normally I would use a Reader and Writer, i.e. something like the following: public static void replace(String oldstring, String newstring, File in, File out) throws IOException { BufferedReader reader = new BufferedReader(new F...

Are the benefits of SFIO over STDIO still valid?

I have just noticed about a library SFIO for a safe and fast IO processing in C. But it is not very up to date. The last version of library is released in 2005 and I couldn't assess that if the claimed benefits of SFIO over STDIO are still valid with comparison to the recent releases of standard IO library. Also Would it be reasonable to...

Make Clojure recognize and isolate the line in a file

Hi! I am trying to get Clojure to read a file, put the first line in a variable, and the rest in another variable. I cannot seem to find out how to do this and would love if anyone could give me a heads up, ...

Open InputStream as Reader

Can I easily convert InputStream to BufferedReader using Guava? I'm looking for something like: InputStream inputStream = ...; BufferedReader br = Streams.newBufferedReader(inputStream); I can open files using the Files.newReader(File file, Charset charset). That's cool and I want to do the same using the InputStream. UPDATE: Using...

Java command lastModified() not working in Clojure

I am trying to get the last modified time from a file in Clojure, by executing a Java command. By using java.io.File.lastModified I am supposed to be able to get the UNIX-time, this does not work by execution of the script or in the REPL. My code is: (java.io.File.lastModified "/home/lol/lolness.txt") and my error is: java....

A way to strip returned values from java.io.File.listFiles in Clojure

Hi I call a java function in Clojure to get a list of files. (require '[clojure.java.io :as io]) (str (.listFiles (io/file "/home/loluser/loldir"))) And I get a whole bunch of strings like these #<File /home/loluser/loldir/lolfile1> etc. How do I get rid of the brackets and put them in some form of an array so another function can...

How can be implemented non-blocking disk I/O?

I'm interested in file and raw. ...

InputStream vs InputStreamReader

What's the benefit of using InputStream over InputStreamReader, or vice versa. Here is an example of InputStream in action: InputStream input = new FileInputStream("c:\\data\\input-text.txt"); int data = input.read(); while(data != -1) { //do something with data... doSomethingWithData(data); data = input.read(); } input.close()...

Java - Read a website and NOT the source

OK so I redefined my last program... here it is: import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public class asp { public static void main(String[] args) { try { URL game = new URL("http://localhost/mystikrpg/post.php?players"); ...

8086 Assembly interrupts for reading/writing binary to/from files?

I need to read in about 1KB or so of data at a time, manipulate it, and write it to another file. I need to do this for at least 100 MB. I have never done any file IO in assembly before. What interrupts do I need to call and what needs to be in what registers? ...

append one file to another

I want to append the content of fileA to fileB. As fileA is large, I would like to do this in a memory-efficient way, i.e. without reading the entire content of fileA into memory. ...

Efficient bulk data transfer through I/O in Java

Is there an efficient mechanism in Java for transferring large amounts of data (~10 GB) back and forth between the disk and the network on a low-end machine? Low-end machine meaning a machine with much less than 10 GB of main memory. I want to efficiently transfer ~10GB portions of a file from one machine to another. ...

Accessing serial data on USB COM port

Hi, I have a h/w device connected to my USB port. The device sends serial data to my USB port. It is connected on one of the COM ports. I wanted to know, how can I take these values in a C# desktop client? Thank You ...

Help with Asynchronous I/O

I have been doing a lot of searching and still can't seem to figure out how to fix my issue. I am writing a GUI program (in WinAPI so no MFC please) to communicate with another program (command line based). I am using anonymous pipes since everything is local (but perhaps named pipes would be better?) which then I use CreateProcess(); to...

Read a line containing (large) N reals to an array in Fortran

I've read() down past a header of an input file, and read the value of L on the way. Now I come to a line of L^2 consecutive reals, which I need to input to the elements of an allocatable array A(L,L). Trying character *100 :: buffer read (1,10) buffer 10 format(a(L*10)) results in Error: Syntax error in ...

Why can't open4 read from stdout when the program is waiting for stdin?

I am using the open4 gem and having problems reading from the spawned processes stdout. I have a ruby program, test1.rb: print 'hi.' # 3 characters $stdin.read(1) # block And another ruby program in the same directory, test2.rb: require 'open4' pid, stdin, stdout, stderr = Open4.popen4 'ruby test1.rb' p stdout.read(2) # 2 characters...

Read Anonymous Pipes More than Once while Keeping Connection Open (WinAPI)

So I keep bouncing between named and anonymous pipes and here is my issue. I tried named pipes and they just didn't seem to work properly for what I wanted, so I'm back to anonymous pipes. However, the anonymous pipe needs to read input from a pipe (to a program that I did not create) and continuously read it as more information is avail...

Read a file backwards line by line using fseek

How do I read a file backwards line by line using fseek? code can be helpful. must be cross platform and pure php. many thanks in advance regards Jera ...

optimal way to prepend a file in php

how do I do this. the file can get very big, so good performance is necessary code is helpful. this is what i have so far function prepend($string, $filename) { $context = stream_context_create (); $fp = fopen($filename,'r',1,$context); $tmpname = md5($string); file_put_contents($tmpname,$string); file_put_co...