Encoder Java

Hey,
I have to implement a string encoder in java but i cant understand in which base/unicode is going to be.
Those are a couple of things that the encoder must be able to do:
0xFF Set N equal to the next byte of the input and output N (called an escape action)
0xFE Set N equal to the next byte of the input and output the Nth phrase in the dictionary (called a look
up action)
0xFD Do nothing
0xF0 Do nothing
0xEF Repeat the next instruction 0xF (that is 15) times
0xEE Repeat the next instruction 0xE (that is 14) times
...
...
...
[the encoder will accept files/txt and will do the appropriate encoding]
can anyone tell me how's that thing can be implemented ????
actually i found something online but i don't know if its doing that appropriate job [its in base32]

thanks in advance!
perdoname_Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sciuriwareCommented:
Is this a standard encoding or some local invention?

;JOOP!
0
perdoname_Author Commented:
I've no idea :S:S:S
it just says that  it has a dictionary of 0xFF (that is, 255) phrases. The zeroth phrase is a
byte with value 0x0, the rst phrase is a byte with value 0x1 and so on.
The decompressor reads the input one byte at a time and treats
each one as an instruction:
0xFF Set N equal to the next byte of the input and output N (called an escape action)
0xFE Set N equal to the next byte of the input and output the Nth phrase in the dictionary (called a look
up action)
0xFD Do nothing
...
...
0
_eeCommented:
Those numbers are in hexadecimal.
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

perdoname_Author Commented:
Is that doing the job??


public class Base32 {
    private static final String base32Chars =
        "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
    private static final int[] base32Lookup =
    { 0xFF,0xFF,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, // '0', '1', '2', '3', '4', '5', '6', '7'
      0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // '8', '9', ':', ';', '<', '=', '>', '?'
      0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06, // '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G'
      0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E, // 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'
      0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16, // 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'
      0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF, // 'X', 'Y', 'Z', '[', '\', ']', '^', '_'
      0xFF,0x00,0x01,0x02,0x03,0x04,0x05,0x06, // '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g'
      0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E, // 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o'
      0x0F,0x10,0x11,0x12,0x13,0x14,0x15,0x16, // 'p', 'q', 'r', 's', 't', 'u', 'v', 'w'
      0x17,0x18,0x19,0xFF,0xFF,0xFF,0xFF,0xFF  // 'x', 'y', 'z', '{', '|', '}', '~', 'DEL'
    };

    /**
     * Encodes byte array to Base32 String.
     *
     * @param bytes Bytes to encode.
     * @return Encoded byte array <code>bytes</code> as a String.
     *
     */
    static public String encode(final byte[] bytes) {
        int i = 0, index = 0, digit = 0;
        int currByte, nextByte;
        StringBuffer base32 = new StringBuffer((bytes.length + 7) * 8 / 5);

        while (i < bytes.length) {
            currByte = (bytes[i] >= 0) ? bytes[i] : (bytes[i] + 256); // unsign

            /* Is the current digit going to span a byte boundary? */
            if (index > 3) {
                if ((i + 1) < bytes.length) {
                    nextByte =
                        (bytes[i + 1] >= 0) ? bytes[i + 1] : (bytes[i + 1] + 256);
                } else {
                    nextByte = 0;
                }

                digit = currByte & (0xFF >> index);
                index = (index + 5) % 8;
                digit <<= index;
                digit |= nextByte >> (8 - index);
                i++;
            } else {
                digit = (currByte >> (8 - (index + 5))) & 0x1F;
                index = (index + 5) % 8;
                if (index == 0)
                    i++;
            }
            base32.append(base32Chars.charAt(digit));
        }

        return base32.toString();
    }

    /**
     * Decodes the given Base32 String to a raw byte array.
     *
     * @param base32
     * @return Decoded <code>base32</code> String as a raw byte array.
     */
    static public byte[] decode(final String base32) {
        int i, index, lookup, offset, digit;
        byte[] bytes = new byte[base32.length() * 5 / 8];

        for (i = 0, index = 0, offset = 0; i < base32.length(); i++) {
            lookup = base32.charAt(i) - '0';

            /* Skip chars outside the lookup table */
            if (lookup < 0 || lookup >= base32Lookup.length) {
                continue;
            }

            digit = base32Lookup[lookup];

            /* If this digit is not in the table, ignore it */
            if (digit == 0xFF) {
                continue;
            }

            if (index <= 3) {
                index = (index + 5) % 8;
                if (index == 0) {
                    bytes[offset] |= digit;
                    offset++;
                    if (offset >= bytes.length)
                        break;
                } else {
                    bytes[offset] |= digit << (8 - index);
                }
            } else {
                index = (index + 5) % 8;
                bytes[offset] |= (digit >>> index);
                offset++;

                if (offset >= bytes.length) {
                    break;
                }
                bytes[offset] |= digit << (8 - index);
            }
        }
        return bytes;
    }

    /** For testing, take a command-line argument in Base32, decode, print in hex,
     * encode, print
     *
     * @param args
     */
   
    static public void main(String[] args) {
        if (args.length == 0) {
            System.out.println("Supply a Base32-encoded argument.");
            return;
        }
        System.out.println(" Original: " + args[0]);
        byte[] decoded = Base32.decode(args[0]);
        System.out.print("      Hex: ");
        for (int i = 0; i < decoded.length; i++) {
            int b = decoded[i];
            if (b < 0) {
                b += 256;
            }
            System.out.print((Integer.toHexString(b + 256)).substring(1));
        }
        System.out.println();
        System.out.println("Reencoded: " + Base32.encode(decoded));
    }
   
}

0
_eeCommented:
That looks like it just takes the input and translates them to an alphanumeric character.  What you want is something that takes a hex code and makes it into an instruction.  Kinda like assembly language.  You could accomplish this by reading in the code, and then having a large switch statement with each available code and the Java method that corresponds to that code.  I've attached some rough pseudo code for what I'm talking about.  I'm sure there are much more efficient ways to do this, but I'm trying to explain what exactly your assignment entails, at least the way I'm understanding it.
switch(input code) {
 
case 0x01:
         do some method
         break;
case 0x02:
         do some other method
         break
 
...

Open in new window

0
perdoname_Author Commented:
i dont think that it works in that way because the program it will take just the text file that contains a couple of strings  
0
_eeCommented:
Well, of course, but you would need to parse it.  If you know how you are receiving the input, you can just create a class that parses out the command.  An example overall strategy if the input is 1 command and arguments per line.

1. Read a line from the file.
2. Parse line to separate command from arguments.
3. Use switch to choose which method corresponds to the command.
4. Execute method
0
perdoname_Author Commented:
so in a way it can be done with the above code ??
[i mean after modification]
0
_eeCommented:
I mean the above code looks like it would kind of parse out the instruction, but doing String modification should be the least of your worries.  The more difficult part is getting all the instructions to work properly.  There are many, many resources online that will parse a String for you, but you will have a harder time trying to get the instructions to work properly.

In short, with heavy modification it looks like it might do what you want.  However, it would be much easier to write something yourself or get a more general string parser online =)
0
perdoname_Author Commented:
i still cant get how each of those methods it works   :/:/
0
_eeCommented:
Which method are you referring to?
0
perdoname_Author Commented:
i mean all those instructions :S
i found another code but its doing the other way around at first ..



 

import org.apache.commons.codec.BinaryDecoder;
import org.apache.commons.codec.BinaryEncoder;
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.EncoderException;

/**
 * Hex encoder and decoder.
 *
 * @since 1.1
 * @author Apache Software Foundation
 * @version $Id: Hex.java,v 1.13 2004/04/18 18:22:33 ggregory Exp $
 */
public class Hex implements BinaryEncoder, BinaryDecoder {

    /**
     * Used building output as Hex
     */
    private static final char[] DIGITS = {
        '0', '1', '2', '3', '4', '5', '6', '7',
           '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
    };

    /**
     * Converts an array of characters representing hexidecimal values into an
     * array of bytes of those same values. The returned array will be half the
     * length of the passed array, as it takes two characters to represent any
     * given byte. An exception is thrown if the passed char array has an odd
     * number of elements.
     *
     * @param data An array of characters containing hexidecimal digits
     * @return A byte array containing binary data decoded from
     *         the supplied char array.
     * @throws DecoderException Thrown if an odd number or illegal of characters
     *         is supplied
     */
    public static byte[] decodeHex(char[] data) throws DecoderException {

        int len = data.length;

        if ((len & 0x01) != 0) {
            throw new DecoderException("Odd number of characters.");
        }

        byte[] out = new byte[len >> 1];

        // two characters form the hex value.
        for (int i = 0, j = 0; j < len; i++) {
            int f = toDigit(data[j], j) << 4;
            j++;
            f = f | toDigit(data[j], j);
            j++;
            out[i] = (byte) (f & 0xFF);
        }

        return out;
    }

    /**
     * Converts a hexadecimal character to an integer.
     *  
     * @param ch A character to convert to an integer digit
     * @param index The index of the character in the source
     * @return An integer
     * @throws DecoderException Thrown if ch is an illegal hex character
     */
    protected static int toDigit(char ch, int index) throws DecoderException {
        int digit = Character.digit(ch, 16);
        if (digit == -1) {
            throw new DecoderException("Illegal hexadecimal charcter " + ch + " at index " + index);
        }
        return digit;
    }

    /**
     * Converts an array of bytes into an array of characters representing the hexidecimal values of each byte in order.
     * The returned array will be double the length of the passed array, as it takes two characters to represent any
     * given byte.
     *
     * @param data
     *                  a byte[] to convert to Hex characters
     * @return A char[] containing hexidecimal characters
     */
    public static char[] encodeHex(byte[] data) {

        int l = data.length;

           char[] out = new char[l << 1];

           // two characters form the hex value.
           for (int i = 0, j = 0; i < l; i++) {
               out[j++] = DIGITS[(0xF0 & data[i]) >>> 4 ];
               out[j++] = DIGITS[ 0x0F & data[i] ];
           }

           return out;
    }
      
    /**
     * Converts an array of character bytes representing hexidecimal values into an
     * array of bytes of those same values. The returned array will be half the
     * length of the passed array, as it takes two characters to represent any
     * given byte. An exception is thrown if the passed char array has an odd
     * number of elements.
     *
     * @param array An array of character bytes containing hexidecimal digits
     * @return A byte array containing binary data decoded from
     *         the supplied byte array (representing characters).
     * @throws DecoderException Thrown if an odd number of characters is supplied
     *                   to this function
     * @see #decodeHex(char[])
     */
      public byte[] decode(byte[] array) throws DecoderException {
            return decodeHex(new String(array).toCharArray());
      }
      
    /**
     * Converts a String or an array of character bytes representing hexidecimal values into an
     * array of bytes of those same values. The returned array will be half the
     * length of the passed String or array, as it takes two characters to represent any
     * given byte. An exception is thrown if the passed char array has an odd
     * number of elements.
     *
     * @param object A String or, an array of character bytes containing hexidecimal digits
     * @return A byte array containing binary data decoded from
     *         the supplied byte array (representing characters).
     * @throws DecoderException Thrown if an odd number of characters is supplied
     *                   to this function or the object is not a String or char[]
     * @see #decodeHex(char[])
     */
      public Object decode(Object object) throws DecoderException {
            try {
            char[] charArray = object instanceof String ? ((String) object).toCharArray() : (char[]) object;
                return decodeHex(charArray);
            } catch (ClassCastException e) {
                throw new DecoderException(e.getMessage());
            }
      }
      
    /**
     * Converts an array of bytes into an array of bytes for the characters representing the
     * hexidecimal values of each byte in order. The returned array will be
     * double the length of the passed array, as it takes two characters to
     * represent any given byte.
     *
     * @param array a byte[] to convert to Hex characters
     * @return A byte[] containing the bytes of the hexidecimal characters
     * @see #encodeHex(byte[])
     */
      public byte[] encode(byte[] array) {
            return new String(encodeHex(array)).getBytes();
      }

    /**
     * Converts a String or an array of bytes into an array of characters representing the
     * hexidecimal values of each byte in order. The returned array will be
     * double the length of the passed String or array, as it takes two characters to
     * represent any given byte.
     *
     * @param object a String, or byte[] to convert to Hex characters
     * @return A char[] containing hexidecimal characters
     * @throws EncoderException Thrown if the given object is not a String or byte[]
     * @see #encodeHex(byte[])
     */
      public Object encode(Object object) throws EncoderException {      
            try {
            byte[] byteArray = object instanceof String ? ((String) object).getBytes() : (byte[]) object;
                  return encodeHex(byteArray);
            } catch (ClassCastException e) {
                  throw new EncoderException(e.getMessage());
            }
      }

}


0
_eeCommented:
You don't need to translate the instruction to a different value.  Treat the hex value as an instruction.  This just is just translating the hex value into a different value, which is not what I think you want.
0
perdoname_Author Commented:
i think my program should do something like HexDump does

0
CEHJCommented:
Before we go any further on this one, please change you most recent question on this to a 20 point pointer to this question, with instructions in there to post into this question. Also post a link to the pointer here (yes we DO want a circular reference ;-)) as there is a fuller spec in your latest
0
perdoname_Author Commented:
http://www.experts-exchange.com/Programming/Languages/Java/Q_23145053.html
Sorry for posting just the link of the question but i dont know how to make that point pointer :S
0
CEHJCommented:
>>but i dont know how to make that point pointer :S

1. Delete your new question, having copied the spec to the clipboard
2. Repost a new q for 20 points entitled something like 'Pointer to 500 point q. about an Encoder'
3. Paste the spec in there, together with the url of *this* question
0
perdoname_Author Commented:
i did the pointer question !
hope someone can help me !
0
CEHJCommented:
>>i did the pointer question !

Good. As i mentioned - please post the link to it here
0
CEHJCommented:
The first thing i'd say about this is that the question is somewhat misleading: afaics, the exercise is more about the design of a mini interpreter, so you need to start listening to _ee ;-)
0
perdoname_Author Commented:
actually all these instructions are how the DEcompressor works

My task is to write a compressor no caring how it will work
0
CEHJCommented:
OK, but of course you *do* have to care how it works in the sense that it must perform the inverse functionality of the decompressor such that decompression works correctly
0
perdoname_Author Commented:
Can anyone of you give a look to the code below?
Is that code okay for that task ?

thanks in advance!
import java.lang.String;
import java.util.*;
import java.io.*;
import java.text.ParseException;
 
public class Compressor
{
 
    static final String      REV = "";
 
    public static final int SERIES = 100;
 
 
    public static final char toHex(int v)
    {
        if (v >= 0x0  &&  v <= 0xF)
            return ((char)(v < 0xA ? v+'0' : v-0xA+'A'));
        return ('?');
    }
 
 
    public static final int fromHex(char ch)
    {
        if (ch <= '9')
        {
            if (ch >= '0')
                return (ch-'0');
            return (-1);
        }
 
        if (ch <= 'F')
        {
            if (ch >= 'A')
                return (ch-'A'+0xA);
            return (-1);
        }
 
        if (ch <= 'f')
        {
            if (ch >= 'a')
                return (ch-'a'+0xA);
            return (-1);
        }
 
        return (-1);
    }
 
 
    public static String encode(byte[] data)
    {
        return (encode(data, 0, data.length));
    }
 
 
    public static String encode(byte[] data, int off, int len)
    {
        char[]      ch;
        int      i;
 
        ch = new char[data.length*2];
        i = 0;
 
        while (len-- > 0)
        {
            int            b;
            int            d;
 
            b = data[off++] & 0xFF;
 
            d = b >> 4;
            d = (d < 0xA ? d+'0' : d-0xA+'A');
            ch[i++] = (char) d;
 
            d = b & 0xF;
            d = (d < 0xA ? d+'0' : d-0xA+'A');
            ch[i++] = (char) d;
        }
 
        return (new String(ch));
    }
 
 
 
    public static void main(String[] args) throws IOException
    {
   BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
   String line = reader.readLine(); // Read from stdin
   while (line != null && line.length() > 0) {
       new Compressor().encode(line.getBytes());
       System.out.println(line); // Print to stdout
       line = reader.readLine();
    }
 
    }
 
    public Compressor(){}
}

Open in new window

0
CEHJCommented:
No that won't do. You need, as i mentioned, to reverse the functionality as per the given spec to arrive at a compressor. I suggest you look at some dictionary based compression techniques.

The code given doesn't do very much other than mess with character encodings - to not much effect, since for most encodings, the effect of the method encode(byte[] b) is no different to

new String(b)
0
perdoname_Author Commented:
Is there anything already made that can do at least a part of that task ? i mean something that has been given as a solution before or anything else ... :S:S

thanks anyway
0
CEHJCommented:
Actually, if i remember the spec, if you feed in an ordinary 'ascii' text file to the decoder, you should get out what you put in. Do you have the working Decoder?
0
perdoname_Author Commented:
0
CEHJCommented:
Further to my last comment, the following seems to support my contention:


goose@duck:/tmp$ echo 'abcde' >decomp.txt
 
goose@duck:/tmp$ decompressor/decompressor.i686 <decomp.txt
 
abcde

Open in new window

0
perdoname_Author Commented:
:(
Sorry for asking again .. but is there anything ready for that ?

Thanks anyway
0
CEHJCommented:
Sorry - i don't understand the question...
0
perdoname_Author Commented:
:(
Is there anyone who does ???
0
perdoname_Author Commented:
Actually what i want is:
"Read the file one byte at a time. If a byte is repeated, output the repeat
next instruction N times followed by the instruction on what byte to
output.
For this, you would need classes:
Main (the main program)
Reader (has functions to open, close read files and return bytes)
Writer (has functions to open, wrile and close the compressed file)
Encoder (keeps the state of what was read and produces the compression
instructions)"

If anyone knows / or have something similar to it'd be grateful !

Thanks in advance!
0
CEHJCommented:
0
perdoname_Author Commented:
Can you give a look to the code below ????


import java.io.*;
public class LZWCompression {
	
	private static final int BITS 			= 	12;
	private static final int HASHING_SHIFT 	= 	4;
	private static final int MAX_VALUE 		= 	(1 << BITS ) - 1;
	private static final int MAX_CODE 		= 	MAX_VALUE - 1;
	private static final int TABLE_SIZE 	= 	5021;
	private static final int EOF			= 	-1;
	
	private BufferedInputStream  input  = null;
	private BufferedOutputStream output = null;
	
	private int output_bit_count  = 0;
	private int output_bit_buffer = 0;
	
	private short[] code_value  		= new short[ TABLE_SIZE ];
	private short[] prefix_code 		= new short[ TABLE_SIZE ];
	private short[] append_character 	= new short[ TABLE_SIZE ];
	
	LZWCompression ( FileInputStream input, FileOutputStream output )
	{
		this.input  = new BufferedInputStream(  input  );
		this.output = new BufferedOutputStream( output );
	}
	
	public void compress()
	{
		short next_code   = 0;
		short character   = 0;
		short string_code = 0;
		short index 	  = 0;
		
		next_code = 256;              			  /* Next code is the next available string code*/
		
		for ( short i = 0; i < TABLE_SIZE; i++ )  /* Clear out the string table before starting */
			code_value[ i ] = -1;
	
		try
		{
			string_code = ( short ) input.read(); /* Get the first character. Assuming it to be 0 - 255
			 									  ** Hence only valid for ASCII text files */
		
			/*
			** This is the main loop where it all happens.  This loop runs util all of
			** the input has been exhausted.  Note that it stops adding codes to the
			** table after all of the possible codes have been defined.
			*/
			while ( ( character = ( short ) input.read() ) != EOF )
			{
				index = find_match ( string_code, character );	/* See if the string is in */
				
				if ( code_value[ index ] != -1 )
			    {            									/* the table.  If it is,   */
					string_code = code_value[ index ];          /* get the code value.  If */
			    }
			    else                                    		/* the string is not in the*/
			    {                                       		/* table, try to add it.   */
			    	if ( next_code <= MAX_CODE )
			    	{
					    code_value		[ index ] = next_code++;
					    prefix_code		[ index ] = string_code;
					    append_character[ index ] = character;
			    	}
			    	
			        output_code( string_code );  				/* When a string is found  */
			    	string_code = character;           			/* that is not in the table */
			    }												/* I output the last string */
			}                                     				/* after adding the new one */
			
			/*
			** End of the main loop.
			*/
			
			output_code( string_code ); 						/* Output the last code               */
			output_code( ( short ) MAX_VALUE );   				/* Output the end of buffer code      */
			output_code( ( short ) 0 );           				/* This code flushes the output buffer*/
			
			/*
			** Close the files
			*/
			output.close();
			input.close();
		}
		catch ( IOException ioe )
		{
			System.out.println( "IOException in compress()" );
			System.exit( 1 );
		}
	}
	
	/*
	** This is the hashing routine.  It tries to find a match for the prefix+char
	** string in the string table.  If it finds it, the index is returned.  If
	** the string is not found, the first available index in the string table is
	** returned instead.
	*/
	private short find_match ( short hash_prefix, short hash_character )
	{
		int index  = 0;
		int offset = 0;
	
		index = ( hash_character << HASHING_SHIFT ) ^ hash_prefix;
		  
		if ( index == 0 )
			offset = 1;
		else
			offset = TABLE_SIZE - index;
		
		while ( true )
		{
			if ( code_value[ index ] == -1 )
				return ( short ) index;
			if ( prefix_code[ index ] == hash_prefix && append_character[ index ] == hash_character )
				return ( short ) index;
		      
			index -= offset;
		    
			if ( index < 0 )
				index += TABLE_SIZE;
		}
	}
	
	private void output_code( short code )
	{
		output_bit_buffer |= code << ( 32 - BITS - output_bit_count );
		output_bit_count += BITS;
		
		while ( output_bit_count >= 8 )
		{
			try
			{
				output.write( output_bit_buffer >> 24 );
			}
			catch( IOException ioe )
			{
				System.out.println( "IOException in output_code()" );
				System.exit( 1 );
			}
			output_bit_buffer <<= 8;
			output_bit_count -= 8;
		}
	}
}
 
 
import java.io.*;
 
public class lzw
{
	public static void main ( String[] args )
	{
		FileInputStream  input  = null;
		FileOutputStream output = null;
		
		if( args[0] == "" )
		{
			System.out.println( "Usage: java lzw <filename>" );
			System.exit( 1 );
		}
		
		try
		{
			input = new FileInputStream( args[0] );
		} 
		catch ( FileNotFoundException fnfe )
		{
			System.out.println( "Unable to open input file: " + args[0] );
			System.exit( 1 );
		}
		
		try
		{
			output = new FileOutputStream( "compressed.lzw" );
		} 
		catch ( FileNotFoundException fnfe )
		{
			System.out.println( "Unable to open output file compressed.lzw " );
			System.exit( 1 );
		}
 
		LZWCompression lzw = new LZWCompression( input, output );
		
		lzw.compress();		/* compress the file */
		
		try
		{
			input.close();
			output.close();
		}
		catch ( IOException ioe )
		{
			System.out.println( "IOException in main()." );
			System.exit(1);
		}
		
		System.out.println( "Done! Compressed file: compressed.lzw");
	}
}
	

Open in new window

0
perdoname_Author Commented:
Can someone give a look to those tests and how can they be fixed??  [above code]

Thanks in advance!

Running test [easy/01] [FAILED on running Compressor]
      Return code was: 1
      Stderr is: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Compressor.main(Compressor.java:10)

Running test [easy/02] [FAILED on running Compressor]
      Return code was: 1
      Stderr is: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Compressor.main(Compressor.java:10)

Running test [easy/03] [FAILED on running Compressor]
      Return code was: 1
      Stderr is: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Compressor.main(Compressor.java:10)

Running test [easy/04] [FAILED on running Compressor]
      Return code was: 1
      Stderr is: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Compressor.main(Compressor.java:10)

Running test [easy/05] [FAILED on running Compressor]
      Exception: [Errno 32] Broken pipe
Running test [hard/01] [FAILED on running Compressor]
      Exception: [Errno 32] Broken pipe
Running test [hard/02] [FAILED on running Compressor]
      Return code was: 1
      Stderr is: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Compressor.main(Compressor.java:10)

Running test [hard/03] [FAILED on running Compressor]
      Exception: [Errno 32] Broken pipe
Running test [hard/04] [FAILED on running Compressor]
      Exception: [Errno 32] Broken pipe
Running test [hard/05] [FAILED on running Compressor]
      Return code was: 1
      Stderr is: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
      at Compressor.main(Compressor.java:10)

Running test [hard/06] [FAILED on running Compressor]
      Exception: [Errno 32] Broken pipe
Running test [hard/07] [FAILED on running Compressor]
      Exception: [Errno 32] Broken pipe

Total marks: 00 out of 80
  Marks for easy (same): 00 of 20
  Marks for easy (comp): 00 of 20
  Marks for hard (same): 00 of 20
  Marks for hard (comp): 00 of 20

0
CEHJCommented:
The decompressor won't work with LZW compression. That example was meant to give you an insight into some similar techniques
0
perdoname_Author Commented:
Is there anyway to make it work ??
0
CEHJCommented:
You would probably be better off (it's nearer) using dictonary-based compression:

http://en.wikipedia.org/wiki/Dictionary_coder
0
perdoname_Author Commented:
Can the LZW Compression be modified in a way to work with the decomporessor ????
0
CEHJCommented:
I think so, but you're going to need to study both in order to do so
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.