I'm having trouble reading through a GZipped BlueCoat log file. The first six lines of the file are a header, and these lines can be read perfectly, but none of the following content.
I have tried unzipping the log manually, and then trying to read the file with slightly modified code, and that works okay. I suspect this is an issue with ASCII versus UTF8 versus UTF16 but I cannot get to the bottom of this, especially since it seems to change mid-file.
Code I have at the moment is:
InputStream fileStream;
InputStream gzipStream;
Reader decoder;
BufferedReader thisBr;
try {
fileStream = new FileInputStream(currentFile);
gzipStream = new GZIPInputStream(fileStream);
decoder = new InputStreamReader(gzipStream, "UTF-8");
thisBr = new BufferedReader(decoder);
String logLine = thisBr.readLine();
while (logLine != null)
{
logWriter.write(logLine + "\n");
logLine = thisBr.readLine();
}
logWriter.flush();
gzipStream.close();
} catch (IOException e) {
System.out.println("Exception has been thrown:" + e);
}