Code example for Deflater

0
		if(messageStr==null) return null;
    	byte[] message=messageStr.getBytes();
    	DeflaterOutputStream dos;
    	ByteArrayOutputStream baos = new ByteArrayOutputStream();
    	 
    	Deflater deflater = new Deflater(Deflater.BEST_COMPRESSION);
		dos = new DeflaterOutputStream(baos,deflater);
		try { 
			dos.write(message, 0, message.length);
			dos.finish();
		} catch (IOException e) { }
		 
		/*GZIPOutputStream gos; 
		try { 
			gos = new GZIPOutputStream(baos); 
			gos.write(message, 0, message.length); 
			gos.finish(); 
		} catch (IOException e) { }*/ 
		 
		if(baos.size() <= 1) {
			Log.w(TAG,"Message is created but not compressed.");