String fileSource = "C:\\input.txt";
try{
byte[] buf = new byte[2048];
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024 * 4);
ZipOutputStream zos = new ZipOutputStream(bos);
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileSource));
ZipEntry ze = new ZipEntry(fileSource);
zos.putNextEntry(ze);
int len;
while ((len = bis.read(buf)) > 0) {
zos.write(buf, 0, len);
}
bis.close();
zos.closeEntry();
zos.close();
// to send compressed file to onMessage method of the QueueReceiver
ByteMessage mMessage = new ByteMessage();
mMessage = mSession.createBytesMessage();
mMessage.writeBytes(bos.toByteArray());
QueueSender.send(mMessage); // this line shows NullPointerException.