import java.io.IOException;
import java.io.InputStream;
+import java.util.Locale;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
pos = 0;
int header = in.read();
if (header != 0x01) {
- throw new IllegalArgumentException(String.format("Header byte 0x01 expected, received 0x%02X", header & 0xFF));
+ throw new IllegalArgumentException(String.format(Locale.ROOT, "Header byte 0x01 expected, received 0x%02X", header & 0xFF));
}
len = readChunk();
}
}
int chunkSize = (w & 0x0FFF) + 1; // plus 3 bytes minus 2 for the length
if ((w & 0x7000) != 0x3000) {
- throw new IllegalArgumentException(String.format("Chunksize header A should be 0x3000, received 0x%04X", w & 0xE000));
+ throw new IllegalArgumentException(String.format(Locale.ROOT, "Chunksize header A should be 0x3000, received 0x%04X", w & 0xE000));
}
boolean rawChunk = (w & 0x8000) == 0;
if (rawChunk) {
if (in.read(buf, 0, chunkSize) < chunkSize) {
- throw new IllegalStateException(String.format("Not enough bytes read, expected %d", chunkSize));
+ throw new IllegalStateException(String.format(Locale.ROOT, "Not enough bytes read, expected %d", chunkSize));
}
return chunkSize;
} else {
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
import org.junit.Test;
0x01, 0x03, (byte)0xB0, 0x02, 0x61, 0x45, 0x00
};
final byte[] expanded = RLEDecompressingInputStream.decompress(compressed);
- final byte[] expected = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".getBytes();
+ final byte[] expected = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa".getBytes(StringUtil.UTF8);
assertArrayEquals(expected, expanded);
}
} catch (final IOException e) {
throw new RuntimeException(e);
}
-
- assertEquals(expected, out.toString());
+ String expanded;
+ try {
+ expanded = out.toString(StringUtil.UTF8.name());
+ } catch (final UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ assertEquals(expected, expanded);
}
}