-2
我想寫一個字節數組到文件。這是代碼的網頁http://allmybrain.com/2012/03/16/quick-convert-raw-g711-ulaw-audio-to-a-au-file/如何將字節數組寫入Java文件
import struct
header = [ 0x2e736e64, 24, 0xffffffff, 1, 8000, 1 ]
o=open('out.au','wb')
o.write (struct.pack (">IIIIII", *header))
raw = open('in.raw','rb').read()
o.write(raw)
o.close()
我轉換爲Java:
byte [] header= { 0x2e736e64, 24, 0xffffffff, 1, 8000, 1 };
FileOutputStream out = new FileOutputStream(file);
out.write(header);
但它是錯誤。你能幫我解決它嗎?謝謝
您需要指定錯誤是什麼。 –
提示:0x2e736e64不是一個字節的有效值... –
是的,我想寫0x2e736e64作爲字節數組。我使用(字節)0x2e736e64。但是數據丟失了。 ASCII是「.snd」 – john2182