diff --git a/src/LZW.java b/src/LZW.java index 037b54d..39413d7 100644 --- a/src/LZW.java +++ b/src/LZW.java @@ -111,4 +111,46 @@ else if (intToBinaryString.length() < bitLength) theOutClass.flush(); } -} \ No newline at end of file + public void decompress(String filename, String outputFilename) + { + PrintWriter output = new PrintWriter(outputFilename); + InputStream reader = new InputStream(filename); + Map dictionary = new HashMap(); + int dictionarySize = 256; + for (int i = 0; i < dictionarySize; i++) + { + Character theChar = (char)i; + String theString = "" + theChar; + dictionary.put(i,theString); + } + StringBuilder newBytes = new StringBuilder(); + int byteRead = reader.read(); + int bitLen = 12; + while (byteRead != -1) + { + String byteStr = byteRead.toBinaryString(); + while(byteStr.length()