我正在尝试将一个字节数组写入一个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”。我做错了什么?
答案 0 :(得分:1)
答案 1 :(得分:1)
ASCII代码0 - 31是控制字符,没有定义的可显示等效项。您可以在此处查看完整表格:http://www.asciitable.com/