Why aren't the results the same when using commons.io.IOUtils
to get byte[]
?
The toByteArray
method params are Inputstream
and Reader
.
String file = "c:/c.pdf";
try (InputStream is = new FileInputStream(file)) {
byte[] result = IOUtils.toByteArray(is);
System.err.println(Arrays.toString(result));
} catch (Exception e) {
e.printStackTrace();
}
try (Reader reader = new FileReader(file)) {
byte[] result = IOUtils.toByteArray(reader,"gbk");
System.err.println(Arrays.toString(result));
} catch (Exception e) {
e.printStackTrace();
}