Android audio transmit with Base64 based on XMPP
来源:互联网 发布:中国 种族歧视 知乎 编辑:程序博客网 时间:2024/06/06 05:17
Base64 encode:
private String filePathToString(String filePath) { byte[] audioBytes; String audioString=""; try { ByteArrayOutputStream baos=new ByteArrayOutputStream(); FileInputStream fis= null; fis = new FileInputStream(new File(filePath)); byte[] buf=new byte[1024]; int n; while (-1!=(n=fis.read(buf))) baos.write(buf,0,n); audioBytes=baos.toByteArray(); audioString= Base64.encodeToString(audioBytes, Base64.DEFAULT); } catch (Exception e) { e.printStackTrace(); } return audioString; }
Base64 decode:
private String stringToFilePath(String fileString) throws IOException { byte[] bytesFile=Base64.decode(fileString,Base64.DEFAULT); String decodedString=new String(bytesFile); File file = null; try { String fileName=generateFileName(); file = new File(Environment.getExternalStorageDirectory() + "/"+fileName); FileOutputStream fos = new FileOutputStream(file, true); fos.write(bytesFile); fos.close(); }catch (Exception e) { e.printStackTrace(); } return file.getAbsolutePath(); }
Reference:
How to get an audio file and encode to base64 string 0 0
- Android audio transmit with Base64 based on XMPP
- The promise of MOM based on XMPP
- An open-source audio search engine based on audio fingerprinting
- streaming audio on android
- USB audio on Android platform
- android overlay based on msm8930
- Transmit
- Video Transmit on Linux Using JMF
- stream audio on android 音频流 android
- My other android app : based on location based service app
- CTreeCtrl/CListCtrl/CListBox With ToolTip Based On the Item Data
- Android Message handling (based on KK4.4)
- Using Password-based Encryption on Android
- 基于Ffmpeg解码器的简单播放器(a simple audio player based on Ffmpeg)
- Farthest points Sampling on 3D meshes with mesh kept based on diffusion distance
- Foreground Estimation Based on Linear Regression Model With Fused Sparsity on Outliers
- Based Off Versus Based On
- [Android]Android FTP server based on Apache FTPServer
- C/C++的一些杂项
- mac下mysql workbench导出数据库
- 同时使用Nohttp和环信出现的问题和解决方案
- MySql-如何查询删除数据表重复记录
- ReactNative动画(下)
- Android audio transmit with Base64 based on XMPP
- MFC CListCtrl的方法
- Android基础之十七使用网络技术
- Android 加载大图(一)
- uva 572 Oil Deposits(油田)—— DFS
- 基础总结篇之三:Activity的task相关
- 菜鸟成长记-初探Swift
- linux 下问题处理
- Android学习笔记三十一:Java异常处理中try,catch,finally的各种组合用法