Can't remember where I read it, but I remember a MS guy saying that once you create a reader around a System.IO.Stream, then the stream is not longer responsible for the disposal of the stream.
Is this true? Can someone confirm this? Maybe provide a reference.
This means the outer using in this code is redundant
using (var s = new Fil...
I inherited a Rails 2.2.2 app that stores user-uploaded images on Amazon S3. The attachment_fu-based Photo model offers a rotate method that uses open-uri to retrieve the image from S3 and MiniMagick to perform the rotation.
The rotate method contains this line to retrieve the image for use with MiniMagick:
temp_image = MiniMagick::Im...
Many hex editors, such as Hex Workshop, can even read large-sized files while keeping a relatively small memory footprint, but still manage to keep scrolling smooth. I'm looking for the best way to achieve this, and so I have several related questions.
Should I just use FileStream?
- Is its buffering based on the current Seek location?...
I have two independant threads F1 and F2 (to be precise, two instances of java.util.concurrent.FutureTask) that are running in parallel.
F1 do some processing, and then copy the result in a XML file. Then, it repeats these steps until it has nothing to do (many XML files are created).
F2 looks in the F1 output directory, and take one fi...
I want to find low-level C/C++ APIs, equivalent with "write" in linux systems, that don't have a buffer. Is there one?
The buffered I/O such as fread, fwrite are not what I wanted.
...
I use this test to convert txt to pdf :
package convert.pdf;
//getResourceAsStream(String name) : Returns an input stream for reading the specified resource.
//toByteArray : Get the contents of an InputStream as a byte[].
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import conver...
I'm writing a console utility to do some processing on files specified on the commandline, but I've run into a problem I can't solve through Google/SO. If a full path, including drive letter, is specified, how do I reformat that path to be relative to the current working directory?
There must be something similar to the VirtualPathUt...
When a file is closed using close() or fclose() (for example), does Linux guarantee that the file is written back to (persistent) disc?
What I mean is, if close() returns 0 and then immediately afterwards the power fails, are previously written data guaranteed to persist, i.e. be durable?
The fsync() system call does provide this guara...
Suppose I have a process which creates a file, writes some data to it, then after a short amount of processing (by itself or another process), deletes it and closes all remaining file descriptors.
I am assuming here that there is enough ram to keep the pages in memory until the file is deleted, and that nobody calls sync() in the interi...
Every time I do anything, and my while(1) gets called in my main function, my file gets cleared. It's driving me crazy. I've tried EVERYTHING. I try to put my ofstream out("data.dat"); outside the while(1) statement so it isn't called everytime but then nothing is written to the file like the ofstream isn't even working!
I've tried to m...
What happens when you concurrently open two (or more) FileOutputStreams on the same file?
The Java API says this:
Some platforms, in particular, allow a file to be opened for writing by only one FileOutputStream (or other file-writing object) at a time.
I'm guessing Windows isn't such a platform, because I have two threads that re...
Hi,
I need to initialize 2D array and first column is every row in a file. How do I get the number of rows in a file?
...
I have a job that runs every night to pull xml files from a directory that has over 20,000 subfolders under the root. Here is what the structure looks like:
rootFolder/someFolder/someSubFolder/xml/myFile.xml
rootFolder/someFolder/someSubFolder1/xml/myFile1.xml
rootFolder/someFolder/someSubFolderN/xml/myFile2.xml
rootFolder/someFolder1
...
hi,
I intend on writing a small download manager in C++ that supports resuming (and multiple connections per download).
From the info I gathered so far, when sending the http request I need to add a header field with a key of "Range" and the value "bytes=startoff-endoff". Then the server returns a http response with the data between th...
Hi,
I am having lots of troubles trying to read a file in C++.
The main problem I'm having is reading properly the first line of the stream since it is different from all the other lines.
A sample file would be:
#Newbie 101|Exam 1|3
Person One|10
Person Two|20
Person Three|30
the first line starts with a # and declares the class nam...
Can anyone please tell my why this method won't compile?
void Statistics::readFromFile(string filename)
{
string line;
ifstream myfile (filename);
if (myfile.is_open())
{
while (! myfile.eof() )
{
getline (myfile,line);
cout << line << endl;
}
myfile.close();
}
else cout << "Unabl...
I am using a Memory mapped file to cache a large amount of data for an ASP.NET application. At the moment I am using the global.asax event to open the file and get a memory mapped file handle which I cache in the application object. If I dereference that handle to a pointer and try to cache the pointer in my httphandler, I get a protec...
I am writing a program in C++ where I have 500 folders, each containing one text file. I want to read each text file from each folder in C++.
How can I accomplish this?
...
I'm writing a program where performance is quite important, but not critical. Currently I am reading in text from a FILE* line by line and I use fgets to obtain each line. After using some performance tools, I've found that 20% to 30% of the time my application is running, it is inside fgets.
Are there faster ways to get a line of text?...
Here is what I want to do and I am wondering if there is any Spring classes that will help with implementing. I don't have to use spring for this particular problem, I'm just implementing it with everything else.
In my DAO layer I want to externalize my sql files aka 1 sql per file. I want to read and cache the sql statement even maybe...