public void saveToSDTemp11Byte(byte[] dataResult,String fileName) { FileOutputStream os = null;//文件输出流用于写文件 String temp=null;//录音数据字符串的形式保存在该文件中,便于做仿真对比 // 数据存储文件 String fileNameTemp = fileName+".txt"; // 获得SD卡路径 File file = new File(Environment.getExternalStorageDirectory(), fileNameTemp); // 判断SD卡是否可用 if (Environment.MEDIA_MOUNTED.equals(Environment .getExternalStorageState())) { try { os=new FileOutputStream(file); try { for(int i=0;i<dataResult.length;i++) { temp=String.valueOf( dataResult[i])+",";//数字转换成字符串 os.write(temp.getBytes()); //Log.i("<<<<",temp); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } finally{ if(os!=null) { try { os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/10698.html