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

谁都会走 提交于 2019-12-10 22:44:49

问题


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.


回答1:


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.




回答2:


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.




回答3:


Try the Java Wav IO library.




回答4:


you could try the plugin : JLayer



来源:https://stackoverflow.com/questions/6358395/convert-wav-file-to-binary-and-then-back-to-wav

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!