.wav文件转换为二进制文件,然后回来为.wav? [英] Convert .wav file to binary and then back to .wav?

查看:220
本文介绍了.wav文件转换为二进制文件,然后回来为.wav?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做在Java中的项目,需要我来加密波形文件。那么,有没有一个简单的过程,波形文件转换成二进制和回来?我将在二进制数据应用的加密算法。

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.

推荐答案

是的。

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();

当然,假设它仍然是一个有效的wav文件,你玩的数据之后。

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

这篇关于.wav文件转换为二进制文件,然后回来为.wav?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆