我使用cordova从iPhone读取/录制音频文件。这将创建一个.wav文件,其内容我想转换为编码字符串以存储在我的数据服务器上。有关如何在java中进行此转换的任何指示?
答案 0 :(得分:1)
File audioFile = new File("fileName.wav");
byte[] bytes = FileUtils.readFileToByteArray(audioFile);
String encoded = Base64.encodeToString(bytes, 0);
Utilities.log("Encoded String: ", encoded);
byte[] decoded = Base64.decode(encoded, 0);
Utilities.log("Decoded String: ", Arrays.toString(decoded));
try
{
File file2 = new File("fileName.wav");
FileOutputStream os = new FileOutputStream(file2, true);
os.write(decoded);
os.close();
}
catch (Exception e)
{
e.printStackTrace();
}