Hello this seems to work fine for smaller files, ie 10 million or so, but when i try to create a 40+ million file i get that Corrup GZIP trailer!
I've tried many combinations of .close, .finish, .flush ect, but for some reason, i quess it's not writing the last buffer of data!
Thanks very much for an insights!
[code]
try
{
textReader = new BufferedReader(new FileReader(xp.dat_file));
GZIPOutputStream gz = new GZIPOutputStream(new FileOutputStream(xp.xml_file));
PrintWriter outf = new PrintWriter(gz);
String line = null; String sToken = null;
String hdr1=("<?xml version=#1.0# encoding=#UTF-8#?>"); hdr1=hdr1.replace('#','"');
outf.write(hdr1+"\n");
outf.write(" <hlp_data>"+"\n");
int pcnt = 0;
while ( (line = textReader.readLine()) != null )
{
pcnt++; debug_cnt++;
if (line.length() < 5) { System.out.println("File has bad data"); break;}
String[] sa = new String[NUM_COLS];
int previ=0; int t=0;int fcnt=0;
for (int s=0;s<line.length();s++)
{
if (line.charAt(s)=='|')
{
sa[t]=line.substring(previ,s);fcnt++;
t++; previ=s+1;
}
}
sa[t]=line.substring(previ,line.length());fcnt++;
if (NUM_COLS!=fcnt) {throw new NullPointerException("ddl cnt != field cnt: "+NUM_COLS+" != fieldcnt:
"+fcnt);}
outf.write(" <"+FILE_NAME+">"+"\n");
if (NUM_COLS==fcnt)
{
for (int i = 0; i < NUM_COLS; i++)
{
if (i>(sa.length-1)) { sToken = new String(); } else { sToken = sa[i]; }
if (sToken.indexOf('<')>-1 || sToken.indexOf('>')>-1 || sToken.indexOf('"')>-1||
sToken.indexOf('&')>-1 )
{
String sToken2 = new String();
sToken2 = normalize(sToken);
sToken = sToken2;
}
outf.write(" <"+_columnNames[i]+">"+sToken+"</"+_columnNames[i]+">"+"\n");
}
}
outf.write(" </"+FILE_NAME+">"+"\n");
}
outf.write("</hlp_data>"+"\n");
textReader.close();
gz.finish();
gz.close();
outf.flush();
outf.close();
}
catch (IOException e) {System.out.println("HlpValPipExtXml1/Error2/reading dat_file" + e);}
}
[\code]