为什么这两个代码块会产生不同的字节数组?
Apache Commons IO 2.4:
Charset iso_8859_1 = Charset.availableCharsets().get("ISO-8859-1");
return IOUtils.toByteArray(new FileReader(getResourceFile(filename)), iso_8859_1);
JDK:
Charset iso_8859_1 = Charset.availableCharsets().get("ISO-8859-1");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(baos, iso_8859_1));
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(getResourceFile(filename)), iso_8859_1));
String line;
while ((line = reader.readLine()) != null)
writer.write(line);
writer.flush();
return baos.toByteArray();
告诉我我在看鬼...