Preserve 1.5 compatibility.

This commit is contained in:
John B. Matthews 2008-08-23 15:51:54 +00:00
parent 005b1f4e07
commit 252cd1607a

View File

@ -86,13 +86,17 @@ public class LzwInputStream extends InputStream {
if (k < dictionary.size()) { if (k < dictionary.size()) {
entry = dictionary.get(k); entry = dictionary.get(k);
} else if (k == dictionary.size()) { } else if (k == dictionary.size()) {
entry = Arrays.copyOf(w, w.length+1); //entry = Arrays.copyOf(w, w.length+1);
entry = new int[w.length+1];
System.arraycopy(w, 0, entry, 0, w.length);
entry[w.length] = w[0]; entry[w.length] = w[0];
} else { } else {
throw new IOException("Invalid code of <" + k + "> encountered"); throw new IOException("Invalid code of <" + k + "> encountered");
} }
for (int i : entry) outputBuffer.add(i); for (int i : entry) outputBuffer.add(i);
int[] newEntry = Arrays.copyOf(w, w.length+1); //int[] newEntry = Arrays.copyOf(w, w.length+1);
int[] newEntry = new int[w.length+1];
System.arraycopy(w, 0, newEntry, 0, w.length);
newEntry[w.length] = entry[0]; newEntry[w.length] = entry[0];
dictionary.add(newEntry); dictionary.add(newEntry);
w = entry; w = entry;