简体   繁体   English

将.wav文件转换为二进制文件,然后再转换为.wav文件?

[英]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. 我在java中做一个项目,需要我加密一个wave文件。 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. 如果您碰巧在Linux系统上,它与字符模式相同。 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. 当然假设在你玩弄数据之后它仍然是一个有效的wav文件。

试试Java Wav IO库。

你可以试试这个插件:JLayer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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