src/jpm/dg/Compression.java
/**
	 * Compresses a String object using the DEFLATE algorithm.
	 * 
	 * @param inputString The text to be compressed.
	 * @return The compressed String.
	 */
Compresses a String object using the DEFLATE algorithm.

@param inputString The text to be compressed.
@return The compressed String.
Compresses a String object using the DEFLATE algorithm . @param inputString The text to be compressed . @return The compressed String .
public static String compress(String inputString) {
		byte[] input;
		try {
			input = inputString.getBytes("ISO-8859-1");
			int originalLength = input.length;
			byte[] buffer = new byte[originalLength * MAX_INCREASE];
			Deflater compresser = new Deflater();
			compresser.setInput(input);
			compresser.finish();
			int compressedLength = compresser.deflate(buffer);
			byte[] output = new byte[compressedLength];
			for (int i = 0; i < output.length; i++) {
				output[i] = buffer[i];
			}
			return new String(output, "ISO-8859-1");
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return inputString;
	}
public static String compress ( String inputString ) { byte [ ] input ; try { input = inputString . getBytes ( "ISO-8859-1" ) ; int originalLength = input . length ; byte [ ] buffer = new byte [ originalLength * MAX_INCREASE ] ; Deflater compresser = new Deflater ( ) ; compresser . setInput ( input ) ; compresser . finish ( ) ; int compressedLength = compresser . deflate ( buffer ) ; byte [ ] output = new byte [ compressedLength ] ; for ( int i = 0 ; i < output . length ; i ++ ) { output [ i ] = buffer [ i ] ; } return new String ( output , "ISO-8859-1" ) ; } catch ( UnsupportedEncodingException e ) { e . printStackTrace ( ) ; } return inputString ; }
Compresses a String object using the DEFLATE algorithm.
Compresses a String object using the DEFLATE algorithm .
// Encode the String into bytes.
 // Compress the bytes.
 // Fill the output array.
