commons.io.IOUtils
为什么使用get时结果不一样byte[]
?
方法toByteArray
参数是Inputstream
和。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();
}