简体   繁体   中英

Convert .wav file to binary and then back to .wav?

I'm doing a project in java which requires me to encrypt a wave file. So, is there a straight forward process to convert a wave file into binary and back? I'll be applying an encryption algorithm on the binary data.

Most languages have utilities to read and write files in binary mode. If you happen to be on a Linux system, it's the same as character mode. In any case, it's not a matter of "converting" to binary, just a different method of reading it.

Yes.

File file = new File("music.wav");
byte[] data = new byte[file.length()];
FileInputStream in = new FileInputStream(file);
in.read(data);
in.close();

//encrypt data

FileOutputStream out = new FileOutputStream(file);
out.write(data);
out.close();

Of course assuming it's still a valid wav file after you play around with the data.

试试Java Wav IO库。

你可以试试这个插件:JLayer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM