Main problem is that I get null result from my zipEntry. What I am doing is getting BLOB.zip from database, directing it to input stream, from there to zipArchiveInputStream and to ZipEntry which returns null every time. I decided to use ZipArchiveInputStream after using ZipInputStream with same null results.
public byte[] getXMLStream() {
try {
return this.jdbcTemplate.queryForObject("SELECT SAVEDATA FROM JDBEVPP1.TEVP005 WHERE GFNR = 357420", byte[].class); }
catch(DataAccessException ex) {
ex.printStackTrace();
return null;}}
@Override
public void getXMLdata() {
byte[] str = getXMLStream();
InputStream myInputStream = new ByteArrayInputStream(str);
ZipArchiveInputStream fis = new ZipArchiveInputStream(myInputStream);
ZipEntry entry = null;
try {
while ( (entry = fis.getNextZipEntry()) != null ) {
System.out.println(entry.getName());
}
} catch (IOException e) {
e.printStackTrace();
}
}
I just need to get this xml and print it in console for testing. Any idea what is wrong here or how to make it work?
EDIT: Inside BLOB is XML format which I need to present on console.
I solve this problem by using GZIPInputStream. It seems it is generic xml at the end..
try {
GZIPInputStream gzip = new GZIPInputStream(bys);
Reader decoder = new InputStreamReader(gzip, "UTF-8");
BufferedReader buffered = new BufferedReader(decoder);
System.out.println(buffered.readLine());
String data = buffered.readLine();
InputSource xml = new InputSource(new StringReader(data));
System.out.println(xml);
} catch (IOException e) {
e.printStackTrace();
}