@Test
public void testWrite() throws IOException {
File file = new File("/home/my.test");
file.createNewFile();
int b = 0x1B, a = 0x78, c = 0x6f, d = 0x3f;
FileOutputStream fos = new FileOutputStream(file);
fos.write(a);
fos.write(b);
fos.write(c);
fos.write(d);
fos.close();
}
如图和代码,我只是想写入四个十六进制的数值进去,并且在 vim 下用%!xxd 下能看到的十六进制的数值只有 4 个。但实际上我看到的却有五个,多了一个0a,这是啥特殊情况呢?求教!
1
Shura 2018 年 5 月 5 日
0A 是换行符(LF),https://en.wikipedia.org/wiki/Newline#Unicode
|
2
e9e499d78f 2018 年 5 月 5 日
vim 自动加的换行符吧
|
4
AllOfMe OP @e9e499d78f 对的
|