java 将 .wav 文件转换为二进制文件,然后再转换回 .wav?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6358395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Convert .wav file to binary and then back to .wav?
提问by Uday Kanth
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.
我正在用java做一个项目,它需要我加密一个wave文件。那么,是否有一个直接的过程可以将波形文件转换为二进制文件并返回?我将对二进制数据应用加密算法。
回答by jpm
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.
大多数语言都有以二进制模式读取和写入文件的实用程序。如果您碰巧在 Linux 系统上,则它与字符模式相同。无论如何,这不是“转换”为二进制的问题,只是一种不同的读取方法。
回答by John
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 文件。
回答by Karl-Bj?rnar ?ie
Try the Java Wav IOlibrary.
试试Java Wav IO库。
回答by shenju
you could try the plugin : JLayer
你可以试试这个插件:JLayer