public boolean replacesFileHeader(String strFillFullPath)
{
boolean bFlag = false;
try{
File infile = new File(strFillFullPath);
BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(infile)));
File outfile = new File(infile + ".tmp");
PrintWriter out = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(outfile))));
String reading;
while ((reading = in.readLine()) != null)
{
if ((reading.contains("HEADER")) || (reading.contains("DONE")))
{
if (reading.contains("HEADER") )
{
out.println("HEADER|GSTEST|***|***");
} else {
out.println("TRAILER|***|DONE");
}
} else {
out.println(reading);
}
}
out.close();
in.close();
infile.delete();
outfile.renameTo(infile);
bFlag = true;
} catch (Exception xe) {
logTestResult("*Error:", false,xe.getLocalizedMessage());
bFlag = false;
}
return bFlag;
}
{
boolean bFlag = false;
try{
File infile = new File(strFillFullPath);
BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream(infile)));
File outfile = new File(infile + ".tmp");
PrintWriter out = new PrintWriter(new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(outfile))));
String reading;
while ((reading = in.readLine()) != null)
{
if ((reading.contains("HEADER")) || (reading.contains("DONE")))
{
if (reading.contains("HEADER") )
{
out.println("HEADER|GSTEST|***|***");
} else {
out.println("TRAILER|***|DONE");
}
} else {
out.println(reading);
}
}
out.close();
in.close();
infile.delete();
outfile.renameTo(infile);
bFlag = true;
} catch (Exception xe) {
logTestResult("*Error:", false,xe.getLocalizedMessage());
bFlag = false;
}
return bFlag;
}