Write simultaneousely to two streams
Is there a way to to couple two streams (or file descriptors) together so that writing to one stream will also write to the second one? (C, Linux) Thanks. ...
Is there a way to to couple two streams (or file descriptors) together so that writing to one stream will also write to the second one? (C, Linux) Thanks. ...
I'm writing a disk crawler and if the user doesn't provide an existing path the program should search all disks that are available. Does anybody know is it possible and if it is how to do that from Java? ...
I am using java.util.Zip and java.util.ZipEntry to successfully extra a zip file's contents to disk. I would like to maintain the file permissions set when extracting on a *nix file-system. Can anyone point me to the "correct" way to do this? ...
Does anyone know where I can find a Stream splitter implementation? I'm looking to take a Stream, and obtain two separate streams that can be independently read and closed without impacting each other. These streams should each return the same binary data that the original stream would. No need to implement Position or Seek and such...
Hi, I'm writing a mini editor component that is much like Notepad++ or UltraEdit that needs to monitor the files the users open - its a bit slimy, but thats the way it needs to be. Is it wise to use multiple instances of FileSystemWatcher to monitor the open files - again like Notepad++ or UltraEdit or is there a better way to manage t...
I am writing a replacement Windows shell in C#, and the feature I am currently implementing is having all IO inside the same shell window - ie, not opening cmd.exe in another window. Right now, I have a partial solution to output. This is my code (where p is the running Process): while ( !p.HasExited ) { /* ... - irrelevant */ ...
this code is correct?? String note = "text.txt"; FileWriter file = new FileWriter(note); Scanner sc = new Scanner(System.in); System.out.println("Enter your name:"); String name = sc.next(); file.close(); How can I pass this file to the program as a command line argument??? ...
Hi all, Hopefully this is a quick and easy question about BufferedOutputStreams and DataOutputStreams in java. When I write bytes to the output stream like myBufferedOutputStream.write(array); myDataOutputStream.write(array); Do these methods write them instantly to the stream and return or do they ever block? I did not see anythi...
I'm currently using a explicit cast to unsigned long long and using %llu to print it, but since size_t has the %z specifier, why clock_t doesn't have one? There isn't even a macro for it. Maybe I can assume that on a x64 system (OS and CPU) size_t has 8 byte in length (and even in this case, they have provided %z), but what about clock_t...
Hello, I am trying to develop a class that reads the standard output of an external program(using an instance of Process, Runtime.getRuntime().exec(cmdLine, env, dir)). The program takes user inputs during the process, and would not proceed until a valid input is given; this seems to be causing a problem in the way I am trying to read it...
I need to write a function that takes in some kind of input stream thing (e.g. an InputStream or a FileChannel) in order to read a large file in two passes: once to precompute some capacities, and second to do the "real" work. I do not want the whole file loaded into memory at once (unless it is small). Is there an appropriate Java clas...
Hey all. I'm reading from one sql-format file to another, and two bytes in the middle are being corrupted, and I assume it's some preparation or safeguard that I didn't do. Example of corrupted data: //From the file that is read from. added ** to emphasize the corrupted byte insert into viruses (virusSig,virusHash) values ( X'579fdc56...
I have an application that writes to a folder on the C:\ drive. The program works fine on my computer, but on another laptop when running the .exe (The other laptop has no visual studio etc.), i get a filenotfoundexception and i cannot pinpoint the line of code where this happens from the error report. Here is the code for creating the ...
So I have a C++ program, that normally when it executes writes out things to a log file. This is done using an fstream. However, now I want to include functionality to turn the logging off. Essentially, my code looks like this: bool isLogging; fstream* logFilePtr; throughout my code, there are a bunch of statements like: (*logFile...
I'm working on a file format that should be written and read in several different operating systems and computers. Some of those computers should be x86 machines, others x86-64. Some other processors may exist, but I'm not concerned about them yet. This file format should contain several numbers that would be read like this: struct Lon...
Using C#, I want to generate 1,000,000 files from DB, each record in separate file. What is the best way to generate this files in minimum time? Here is my code without threading : AppDomain.CurrentDomain.ProcessExit += new EventHandler(CurrentDomain_ProcessExit); // to calculate the execution time in case of using threading SqlCom...
I was playing around with the erlang shell today and noticed that I could do command injections, something like the following: io:get_chars("Cmd> ", 3). Cmd> Dud List=[3,4,5]. io:get_line("I just took over your shell!"). Is there a way to sanitize the get_chars function's input so this isn't possible? ...
Im trying to write a single byte at a certain location in a file. This is what im using at the moment: BinaryWriter bw = new BinaryWriter(File.Open(filename, FileMode.Open)); bw.BaseStream.Seek(0x6354C, SeekOrigin.Begin); bw.Write(0xB0); bw.Close(); The problem is that BinaryWriter.Write(args) writes a four-byte signed integer at the ...
I have text file that looks like this: 1 1 1 1 1 2 3 5 4 4 5 5 I want to read this text file into array of lines and display it. Can anyone help me do this? ...
When an application saves a file, a typical model is to save the file to a temporary location, then move the temporary file to the final location. In some cases that "move" becomes "replace". In pseudo code: Save temp file; if final file exists delete final file; move temp file to final filename; There's a window in there where ...