【发布时间】:2015-02-21 21:03:37
【问题描述】:
我正在尝试将字节数组写入带有FileOutputStream的文件,如下所示:
public static void writeFileContents(String path, byte[] contents) {
try(FileOutputStream stream = new FileOutputStream(path)) {
stream.write(contents);
} catch (IOException e) {
e.printStackTrace();
}
}
contents 的填充方式如下:
byte[] bytes = new byte[32 * 32];
Arrays.fill(bytes, (byte) 2);
但我在文件中收到了奇怪的字符,它是白框中的字母“STX”。我做错了什么?
【问题讨论】:
标签: java byte fileoutputstream