dcsimg
What is the fastest way to write a file.
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Eric_Weborg
Posted On:   Wednesday, October 24, 2001 08:58 AM

I'm currently using Filewriter to write a file. I was writing about 75 lines of text to the file with no problems. The requirement has changed and it needs write over 17,000 lines of text to the file. It is taking 3hours and 45minutes to complete. Is there a better way to create a file? Source: public void writeLog(String logRecord) { try { FileWriter out = new FileWriter(fileDir + "\" + fileName, true); out.write(logRecord); out.flush(); out.close(); } catch (IOException e) { System.err.println(e); } } public void newWrite(String logRecord) { try { FileWriter out = new FileWriter(fileDir   More>>

I'm currently using Filewriter to write a file. I was writing about 75 lines of text to the file with no problems. The requirement has changed and it needs write over 17,000 lines of text to the file. It is taking 3hours and 45minutes to complete. Is there a better way to create a file?

Source:
public void writeLog(String logRecord)
{
try
{
FileWriter out = new FileWriter(fileDir + "\" + fileName, true);
out.write(logRecord);
out.flush();
out.close();
}
catch (IOException e)
{
System.err.println(e);
}
}

public void newWrite(String logRecord)
{
try
{
FileWriter out = new FileWriter(fileDir + "\" + fileName, false);
out.write(logRecord);
out.flush();
out.close();
}
catch (IOException e)
{
System.err.println(e);
}
}

   <<Less

Re: What is the fastest way to write a file.

Posted By:   John_Zukowski  
Posted On:   Sunday, October 28, 2001 08:49 PM

Look into using BufferedWriter.
About | Sitemap | Contact