My this blog is not dependent to any language platform it might help in java, python or any programming methodology because i have proposed an idea how to cater with a single file with millions of I/O in it.
Recently I had one task which seem not possible to write a million of stream (text) on a file from different hops. I had tried but I always get an exception that file is in used by another process and drop in to the exception.
What I have done , I proposed a solution which is working perfectly since 6 month and a single file able to write around 1 mb of text in a minute and reply to all multiple threads invoked and used file for I/O.
bool _FileUse = false;
while (!_FileUse)
{
try
{
StreamWriter strWriter = new
StreamWriter(p_directoryPath + p_Filename + ".txt", true);
strWriter.Write(_Builder);
strWriter.AutoFlush = true;
strWriter.Flush();
strWriter.Dispose();
strWriter.Close();
Thread.Sleep(1000);
_FileUse = true;
}
catch (Exception ex)
{
Thread.Sleep(1000);
_FileUse = false;
}
}
So its seems like a simple coding with a very big fake sing for a compiler :D. Hope this may help it.
make life easy:
Monday, March 15, 2010
Subscribe to:
Posts (Atom)