我正在使用Java将字节数组写入文件.当我在十六进制编辑器中打开我的文件时,我并不总是看到我期望在那里的字节.这是我的示例代码和输出文件的内容:
public static void main(String[] args)
{
File file = new File( "c:\\temp\\file.txt" );
file.delete();
FileOutputStream outStream = null;
try
{
file.createNewFile();
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
try
{
outStream = new FileOutputStream( file );
} catch (FileNotFoundException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
try
{
outStream.write( new byte[] { 0x14, 0x00, 0x1F, 0x50 } );
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
当我在十六进制编辑器中打开文件时,我获取 …